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

log4Net 简单配置实用

时间:2014-12-23 13:50:04      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>
View Code
技术分享
  <log4net debug="false">
    <appender name="LogFileAppender" type="log4net.Appender.FileAppender" >
      <!--日志存放位置-->
      <param name="File" value="c:\ResourceMgrLog\" />
      <param name="datePattern" value="yyyy-MM-dd HH:mm" />
      <param name="AppendToFile" value="true" />
      <param name="MaxSizeRollBackups" value="10" />
      <param name="MaximumFileSize" value="5MB" />
      <param name="StaticLogFileName" value="false" />
      <param name="DatePattern" value="yyyy-MM-dd.LOG" />
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
      </layout>
    </appender>
    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
      <!--日志存放位置-->
      <param name="File" value="C:\ResourceMgrLog\" />
      <param name="AppendToFile" value="true" />
      <param name="StaticLogFileName" value="false" />
      <param name="DatePattern" value="yyyy-MM-dd.LOG" />
      <param name="MaxSizeRollBackups" value="10" />
      <param name="MaximumFileSize" value="5MB" />
      <param name="RollingStyle" value="Date" />
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
      </layout>
    </appender>
    <root>
      <level value="DEBUG" />
      <appender-ref ref="LogFileAppender" />
      <appender-ref ref="RollingLogFileAppender" />
    </root>
  </log4net>
View Code

Global.asax中的 Application_Start方法下添加:

log4net.Config.XmlConfigurator.Configure();
 private static readonly ILog log = LogManager.GetLogger(typeof(FixedAssetManagement));

log.Debug("",ex);

 

log4Net 简单配置实用

标签:

原文地址:http://www.cnblogs.com/fangyangwa/p/4179915.html

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