log4net 配置
Posted kikyoqiang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了log4net 配置相关的知识,希望对你有一定的参考价值。
xml
<configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> </configSections> <log4net> <!-- OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL --> <!-- Set root logger level to ERROR and its appenders --> <root> <level value="DEBUG" /> <appender-ref ref="RollingFileTracer" /> </root> <!-- Print only messages of level DEBUG or above in the packages --> <appender name="RollingFileTracer" type="log4net.Appender.RollingFileAppender,log4net"> <param name="File" value="App_Data/Log/" /> <param name="AppendToFile" value="true" /> <param name="RollingStyle" value="Composite" /> <param name="MaxSizeRollBackups" value="10" /> <param name="MaximumFileSize" value="1MB" /> <param name="DatePattern" value=""Logs_"yyyyMMdd".txt"" /> <param name="StaticLogFileName" value="false" /> <layout type="log4net.Layout.PatternLayout,log4net"> <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" /> </layout> </appender> </log4net> </configuration>
MvcApplication
log4net.Config.XmlConfigurator.Configure();
代码
private static ILog log = LogManager.GetLogger(typeof(ZSZDbContext));
以上是关于log4net 配置的主要内容,如果未能解决你的问题,请参考以下文章