Log4net对文件的支持

RollingFileAppender循环记录日志(指定文件最大长度)

<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
  <file value="RollingFileAppender_log.txt" />
  <appendToFile value="true" />
  <rollingStyle value="Size" />
  <maxSizeRollBackups value="10" />
  <maximumFileSize value="100KB" />
  <staticLogFileName value="true" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] (%file:%line) %-5level %logger [%property{NDC}] - %message%newline" />
  </layout>
</appender>

RollingFileAppender循环记录日志(按日期记录)

<appender name="RollingLogFileAppender_DateFormat" type="log4net.Appender.RollingFileAppender">
  <file value="RollingLogFileAppender_DateFormat_log.txt" />
  <appendToFile value="true" />
  <rollingStyle value="Date" />
  <!--<datePattern value="yyyyMMdd-HHmm" />-->
  <datePattern value="yyyyMMdd" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread](%file:%line) %-5level %logger [%property{NDC}] - %message%newline" />
  </layout>
</appender>

 

posted on 2014-07-06 10:41  AngelLee2009  阅读(212)  评论(0编辑  收藏  举报

导航