I've currently got a log4net rolling file appender, based on date that should be rolling over each day. It has been doing that for months without a problem - but in the last week it has begun overwriting the existing log at some point during the day. It seems to be doing that when the log file has hit around 10mb.

This is the config:

<appender name="Standard" type="log4net.Appender.RollingFileAppender">
  <file value="..\..\Logs\" />
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
  <staticLogFileName value="false" />
  <datePattern value="yyyy-MM-dd'.log'" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%d{yyyy-MM-dd HH:mm} %-5level %message%newline%exception" />
  </layout>
  <filter type="log4net.Filter.LevelRangeFilter">
    <levelMin value="DEBUG" />
    <levelMax value="WARN" />
  </filter>
</appender>

My theory is that the rolling style isn't specified, and a maximum size isn't specified, and the default setting for each is Composite and 10mb. Therefore when it reaches 10mb it starts to roll over, and since the static log file name is set to false, it just rewrites over the current file.

Is that the case? Or is there some other issue at work here? I've added

<rollingStyle value="Date"/> 

now, and will see how it goes. But getting an explanation of why this happened would be great.

Thanks!

有帮助吗?

解决方案

It looks like my theory was correct! The default file size is 10mb, and the default rolling style is composite. Combined with the non static file name, when it reached 10mb, it just rolled over to the same file and began logging again.

其他提示

You could always change your date pattern

 <param name="DatePattern" value="yyyy-MM-dd-hh'.log'" />
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top