1.global.asax file
Copy Code code as follows:
void Application_Start (object sender, EventArgs e)
{
Code that runs when the application starts
Log4net. Config.XmlConfigurator.ConfigureAndWatch (New System.IO.FileInfo (Sxmobi.FileHelper.GetMapPath) ("~\\log4net.config ")));
}
2.log4net.config file
Copy Code code as follows:
<?xml version= "1.0" encoding= "Utf-8"?>
<configuration>
<configSections>
<section name= "log4net" type= "log4net". Config.log4netconfigurationsectionhandler,log4net "/>
</configSections>
<log4net debug= "false" >
<!--Configure logging related parameters-->
<!--comments section generates a single log file by date-->
<appender name= "Debuglogger" type= "log4net". Appender.rollingfileappender ">
<!--<param name= "File" value= "D:\Webroot\SXH\DocOnline\web\Log\"/>-->
<param name= "File" value= "Log\debug.txt"/>
<param name= "Appendtofile" value= "true"/>
<param name= "maxsizerollbackups" value= "ten"/>
<!--<param name= "Staticlogfilename" value= "false"/>
<param name= "Datepattern" value= "Yyyy-mm-dd". Log ""/>-->
<param name= "Rollingstyle" value= "Date"/>
<layout type= "log4net. Layout.patternlayout ">
<param name= "Conversionpattern" value=%n[header]%n%d [%t]%-5p%c [%x] [%x{auth}]%n-%m%n[footer]%n]/>
</layout>
</appender>
<!--to use a different log file, add a Appender node above and set the file value.
Then add a logger node below to-->
<root>
<!--(high) off > FATAL > ERROR > WARN > INFO > DEBUG > All (Low)-->
<level value= "DEBUG"/>
<appender-ref ref= "Debuglogger"/>
</root>
</log4net>
</configuration>