码迷,mamicode.com
首页 > Web开发 > 详细

log4net配置

时间:2018-08-27 18:34:51      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:sel   out   neu   eset   config   start   evel   nta   sof   

在AssemblyInfo.cs文件中添加[assembly: log4net.Config.XmlConfigurator(Watch = true)];

或者在Global.asax文件中执行:

void Application_Start(object sender, EventArgs e)
{
//在应用程序启动时运行的代码
log4net.Config.DOMConfigurator.Configure();

}

app.config中配置如下:

<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>

<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="C:\LogFile\ADSync.log.txt" />
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="10" />
<param name="MaximumFileSize" value="5MB" />
<param name="RollingStyle" value="Size" />
<param name="StaticLogFileName" value="false" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>

log4net配置

标签:sel   out   neu   eset   config   start   evel   nta   sof   

原文地址:https://www.cnblogs.com/johnblogs/p/9542546.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!