I have a Log4Net RollingFileAppender that is configured as:
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
<root>
<level value="ALL" />
</root>
<logger name="RollingFileAppender" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="RollingFileAppender" />
</logger>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender" >
<param name="File" value="C:\\MyLog.log" />
<param name="AppendToFile" value="true" />
<param name="DatePattern" value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%m%n"/>
</layout>
</appender>
</log4net>
</configuration>
Looking at the documentation, the The default rolling style is Composite, so it makes sense this will roll when it reaches a certain size (the default of 10MB), not just on the date.
The problem is when it hits the size, it is restarting the log and I am losing the data from the first half of the day (it reaches this size around noon).
Why wouldn't this just roll to a new file and all future log lines are put into the MyLog.log?
Or is it the log is rolling, but then at midnight, it is rolling again and overwritting the dated log (eg. rolling to MyLog.log2009-04-08 once it reaches 10MB, and then overwritting this same file at midnight)?
I will set the
<rollingStyle value="Date" />
Is this all I have to do to ensure it only rolls on the Date boundary? Can I change this on the fly in the Log4Net.config, or do I have to restart the application? It is running on IIS6.