开发者

RollingFileAppender doesn't roll over anymore after a couple of weeks

I'm using log4net (v1.2.9.0) in a web project. Everything works like a charm, but after a couple of weeks the RollingFileAppender stopped to roll over. Instead, every log message is appended to the same file which therefore has a giant size by now.

Here is my log4net configuration:

<?xml version="1.0" encoding="utf-8"?>
<log4net>
  <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
  <par开发者_如何转开发am name="File" value="C:\\Documents and Settings\\All Users\\Application Data\\CAPServer\\log\\CWSServer.log"/>
  <param name="AppendToFile" value="true"/>
  <param name="MaxSizeRollBackups" value="50"/>
    <param name="RollingStyle" value="Date"/>
    <param name="DatePattern" value="yyyyMMdd"/>
    <param name="StaticLogFileName" value="true"/>
  <layout type="log4net.Layout.PatternLayout">
   <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} [%t] %-5p %c{1} - %m%n"/>
  </layout>
 </appender>
 <root>
  <level value="ALL"/>
  <appender-ref ref="RollingLogFileAppender"/>
 </root>
</log4net>


A couple of things to try from the documentation on http://logging.apache.org/log4net/release/sdk/log4net.Appender.RollingFileAppender.html:

Try removing the entry for MaxSizeRollBackups.

CAUTION
A maximum number of backup files when rolling on date/time boundaries is not supported.

Try clearing out the directory of all log files.

CAUTION
Changing StaticLogFileName or CountDirection without clearing the log file directory of backup files will cause unexpected and unwanted side effects.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜