Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
MVC Log4Net integration example File and database logs
Fetching latest commit…
Cannot retrieve the latest commit at this time.
|Type||Name||Latest commit message||Commit time|
|Failed to load latest commit information.|
# mvc_Log4Net MVC Log4Net integration example File and database logs This is a straightforward integration of Log4Net into a minimal ASP.NET MVC Web Application Follow the following steps to make this work on your system 1. Run the .sql file in mvc_Log4Net\Models (Edit this for your needs as necessary but remember that you will have to change all references): create_App_Log.sql 2. Import the database table as an Entity Framework Model from the database. you should get a web.config entry like the following: <connectionStrings> <!--//***Log4Net_Test EF6 connection string generated by importing database table LogEntries--> <add name="App_LogEntities" connectionString="metadata=res://*/Log4Net_Model.csdl|res://*/Log4Net_Model.ssdl|res://*/Log4Net_Model.msl;provider=System.Data.SqlClient;provider connection string="data source=.\sqlexpress;initial catalog=App_Log;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /> </connectionStrings> Then search for the pattern "//***Log4Net_Test" to find all the modifications made to a default VS2015 ASP.NET MVC .NET web application The above preparations and all other edits are returnd by searching for the pattern "//***Log4Net_Test" in all project .cs and .cshtml files: C:\Projects\__Public\POC\mvc_Log4Net\mvc_Log4Net\Controllers\HomeController.cs(13): //***Log4Net_Test C:\Projects\__Public\POC\mvc_Log4Net\mvc_Log4Net\Controllers\Log4Net_TestController.cs(9)://***Log4Net_Test: include this entire file C:\Projects\__Public\POC\mvc_Log4Net\mvc_Log4Net\Global.asax.cs(20): //***Log4Net_Test: Initializer, no output without this configuration, make sure your log4net.config file is in the web application root C:\Projects\__Public\POC\mvc_Log4Net\mvc_Log4Net\Log.cs(6)://***Log4Net_Test: include this entire file C:\Projects\__Public\POC\mvc_Log4Net\mvc_Log4Net\Views\Home\Index.cshtml(9): @* //***Log4Net_Test default test entry link *@ C:\Projects\__Public\POC\mvc_Log4Net\mvc_Log4Net\Views\Log4Net_Test\Index.cshtml(5):@* //***Log4Net_Test: shows how to generate test log entries and view them *@ Run the app and select 'Generate test log entries'. Suerte.