log4net配置分析

2021-06-06 13:01

阅读:493

标签:back   logs   滤波器   end   范围   size   debug   deb   err   

appender   附加器

RollingFileAppender      滚动文件appender

MaxSizeRollBackups      最大尺寸回滚

ConversionPattern      转换模式

LevelRangeFilter      电平范围滤波器

PatternLayout      图案布局

log4net配置在节点configuration下面

log4net>
    appender name="ErrorLog" type="log4net.Appender.RollingFileAppender">
      param name="File" value="log\Error.Log.txt"/>
      param name="AppendToFile" value="true"/>
      param name="MaxSizeRollBackups" value="10"/>
      param name="MaximumFileSize" value="1MB"/>
      param name="RollingStyle" value="Size"/>
      param name="StaticLogFileName" value="true"/>
      layout type="log4net.Layout.PatternLayout">
        param name="ConversionPattern" value="%d [%t] %-5p %c  - %m%n"/>
      layout>
      filter type="log4net.Filter.LevelRangeFilter">
        param name="LevelMax" value="ERROR"/>
        param name="LevelMin" value="ERROR"/>
      filter>
    appender>
    appender name="InfoLog" type="log4net.Appender.RollingFileAppender">
      param name="File" value="log\Info.Log.txt"/>
      param name="AppendToFile" value="true"/>
      param name="MaxSizeRollBackups" value="10"/>
      param name="MaximumFileSize" value="1MB"/>
      param name="RollingStyle" value="Size"/>
      param name="StaticLogFileName" value="true"/>
      layout type="log4net.Layout.PatternLayout">
        param name="ConversionPattern" value="%d [%t] %-5p %c  - %m%n"/>
      layout>
      filter type="log4net.Filter.LevelRangeFilter">
        param name="LevelMax" value="INFO"/>
        param name="LevelMin" value="INFO"/>
      filter>
    appender>
    appender name="DebugLog" type="log4net.Appender.RollingFileAppender">
      param name="File" value="log\Debug.Log.txt"/>
      param name="AppendToFile" value="true"/>
      param name="MaxSizeRollBackups" value="10"/>
      param name="MaximumFileSize" value="1MB"/>
      param name="RollingStyle" value="Size"/>
      param name="StaticLogFileName" value="true"/>
      layout type="log4net.Layout.PatternLayout">
        param name="ConversionPattern" value="%d [%t] %-5p %c  - %m%n"/>
      layout>
      filter type="log4net.Filter.LevelRangeFilter">
        param name="LevelMax" value="DEBUG"/>
        param name="LevelMin" value="DEBUG"/>
      filter>
    appender>
    root>
      level value="all"/>
      appender-ref ref="InfoLog"/>
      appender-ref ref="ErrorLog"/>
      appender-ref ref="DebugLog"/>
    root>
  log4net>

configSections下面配置

 section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>

 

log4net配置分析

标签:back   logs   滤波器   end   范围   size   debug   deb   err   

原文地址:http://www.cnblogs.com/Tpf386/p/7338570.html


评论


亲,登录后才可以留言!