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

log4net的配置

时间:2016-04-18 16:53:39      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

 

  <configSections>
    <section name ="log4net" type ="System.Configuration.IgnoreSectionHandler"/>
  </configSections>
  <log4net>
    <appender name="errorAppender" type="log4net.Appender.RollingFileAppender">
      <filter type="log4net.Filter.LevelMatchFilter">
        <levelToMatch value="ERROR" />
      </filter>
      <filter type="log4net.Filter.DenyAllFilter" />
      <File value="Logs\err.log" />
      <PreserveLogFileNameExtension value="true" />
      <appendToFile value="true" />
      <rollingStyle value="Date" />
      <datePattern value="yyyyMMdd" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <appender name="infoAppender" type="log4net.Appender.RollingFileAppender">
      <filter type="log4net.Filter.LevelMatchFilter">
        <levelToMatch value="INFO" />
      </filter>
      <filter type="log4net.Filter.DenyAllFilter" />
      <File value="Logs\info.log" />
      <PreserveLogFileNameExtension value="true" />
      <appendToFile value="true" />
      <rollingStyle value="Date" />
      <datePattern value="yyyyMMdd" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <appender name="debugAppender" type="log4net.Appender.RollingFileAppender">
      <filter type="log4net.Filter.LevelMatchFilter">
        <levelToMatch value="DEBUG" />
      </filter>
      <filter type="log4net.Filter.DenyAllFilter" />
      <File value="Logs\debug.log" />
      <PreserveLogFileNameExtension value="true" />
      <appendToFile value="true" />
      <rollingStyle value="Date" />
      <datePattern value="yyyyMMdd" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <appender name="perfAppender" type="log4net.Appender.RollingFileAppender">
      <filter type="log4net.Filter.LevelMatchFilter">
        <levelToMatch value="INFO" />
      </filter>
      <filter type="log4net.Filter.DenyAllFilter" />
      <File value="Logs\perf.log" />
      <PreserveLogFileNameExtension value="true" />
      <appendToFile value="true" />
      <rollingStyle value="Date" />
      <datePattern value="yyyyMMdd" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date %logger - %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="ALL" />
      <appender-ref ref="errorAppender" />
      <appender-ref ref="infoAppender" />
      <appender-ref ref="debugAppender" />
    </root>
    <logger name="Performance" additivity="false">
      <level value="ALL" />
      <appender-ref ref="perfAppender" />
    </logger>
  </log4net>

 

log4net的配置

标签:

原文地址:http://www.cnblogs.com/chucklu/p/5404813.html

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