1, installation Log4net
2. References
3. Configuration (Web. config file)
<configSections>
<section name= "log4net" type= "log4net. Config.log4netconfigurationsectionhandler, log4net "/>
</configSections>
<log4net>
<!--information Log configuration-
<appender name= "Infoappender" type= "log4net. Appender.rollingfileappender ">
<param name= "File" value= "log\\"/>
<param name= "Appendtofile" value= "true"/>
<param name= "MaxFileSize" value= "10240"/>
<param name= "maxsizerollbackups" value= "/>"
<param name= "Staticlogfilename" value= "false"/>
<param name= "Datepattern" value= "YyyyMMdd '. Log '"/>
<param name= "Rollingstyle" value= "Date"/>
<layout type= "log4net. Layout.patternlayout ">
<param name= "Conversionpattern" value= "%ndate:%d, level:%-5p%n%m%n"/>
</layout>
</appender>
<!--level:off,fatal,error,warn,info,debug,all-->
<root>
<level value= "ERROR"/>
<appender-ref ref= "Infoappender"/>
</root>
</log4net>
4. Call (Global.asax.cs file (I am the log4net logging plugin used in the. NET MVC project, the following sentence is usually placed at the entrance of the program))
protected void Application_Start ()
{
Log4net. Config.XmlConfigurator.Configure ();
}
5, use (before use, first add a folder named Log in the root directory of the project)
Public readonly static ILog Log = Logmanager.getlogger (typeof (Basecontroller));
Log.error ("SAP disables exceptions! ", ex);
This article is from the "11075795" blog, please be sure to keep this source http://11085795.blog.51cto.com/11075795/1859310
Use of the Log4net log plugin