I have a log4net logger in an IIS-hosted WCF service. The logger is configured as a rolling file appender by size. The service is deployed to 3 different environments - QA, TEST and PROD.
The problem, which only happens on QA environment, is that no old log files are being saved. When a new log file is opened, it replaces the old file.
This is the log4net configuration from the QA environment which has the problem:
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
<appender name="B2BAppender" type="log4net.Appender.RollingFileAppender, log4net">
<!--<param name="File" type="log4net.Util.PatternString" value="Log/%property{LogName}"/>-->
<param name="File" type="log4net.Util.PatternString" value="Log/B2BService.log"/>
<param name="AppendToFile" value="true"/>
<param name="RollingStyle" value="Size"/>
<param name="MaximumFileSize" value="50KB"/>
<param name ="MaxSizeRollBackups" value="-1"/>
<param name="StaticLogFileName" value="true"/>
<param name="countDirection" value="1"/>
<param name="PreserveLogFileNameExtension" value="true"/>
<layout type="log4net.Layout.PatternLayout, log4net">
<param name="ConversionPattern" value="%date{dd/MM/yyyy HH:mm:ss.fff} [%level]: %message"/>
</layout>
</appender>
<logger name="B2BLog">
<level value="ALL"/>
<appender-ref ref="B2BAppender"/>
</logger>
</log4net>
In this environment, the file B2BService.log is being overridden every time. No old log files are preserved.
This is the log4net configuration from the PROD environment which works OK:
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
<appender name="B2BAppender" type="log4net.Appender.RollingFileAppender, log4net">
<!--<param name="File" type="log4net.Util.PatternString" value="Log/%property{LogName}"/>-->
<param name="File" type="log4net.Util.PatternString" value="Log/B2BService.log"/>
<param name="AppendToFile" value="true"/>
<param name="RollingStyle" value="Size"/>
<param name="MaximumFileSize" value="10MB"/>
<param name ="MaxSizeRollBackups" value="-1"/>
<param name="StaticLogFileName" value="true"/>
<param name="countDirection" value="1"/>
<param name="PreserveLogFileNameExtension" value="true"/>
<layout type="log4net.Layout.PatternLayout, log4net">
<param name="ConversionPattern" value="%date{dd/MM/yyyy HH:mm:ss.fff} [%level]: %message%newline"/>
</layout>
</appender>
<logger name="B2BLog">
<level value="ALL"/>
<appender-ref ref="B2BAppender"/>
</logger>
</log4net>
In this environment, old log files are being preserved with names B2BService.1.log, B2BService.2.log etc.
As you can see, the only differences are the MaximumFileSize (which is way too small in QA, I know, will be changed) and the ConversionPattern. Both shouldn't affect the file rolling by size.
Any ideas?