1. Introduction of log4net
Download and introduce log4net. dll in a web project
2. Place log4net. config in the root directory of the web project.
3. Add code in application_start of Global
Log4net. config. xmlconfigurator. configureandwatch (new system. Io. fileinfo (server. mappath ("~ /") +" Log4net. config "));
4. Declare and assign values to the base page class
For example, private ilog _ logger = NULL;
/// <Summary>
/// System Log Interface
/// </Summary>
Public ilog Logger
{
Get {return _ logger ;}
}
Protected override void onload (eventargs E)
{
_ Logger = logmanager. getlogger (this. GetType ());
Base. onload (E );
}
5. Use
Use logger directly on the page.
If there is no step 4, you can create and use it directly,
For example, logmanager. getlogger (this. GetType ());
Welcome to: http: // 121.18.78.216, which is a demonstration platform for ease of query and analysis, workflow, content management, and project management.