logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mohkam Singh Sawhney <singh...@yahoo.com>
Subject RollingFileAppender overwriting previous log files on application restart
Date Thu, 14 Aug 2014 10:31:39 GMT

I am using log4Net v1.2.13 in a .NET 4 C# project. I have setup a RollingFileAppender to roll
on size. My aim is to keep appending to a log file and roll on size. I need to maintain all
the previous log files. But I found that every time my application restarts all the log
files after the 2nd log file that was generated in the previous run get overwritten.

For testing purposes I set the rollover size to 3KB. Below is the appender configuration.

<appender name="RollingAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs22\myFile_d.log" />
<appendToFile value="true" />
<rollingStyle value="size" />
<staticLogFileName value="false" />
<maximumFileSize value="3KB" />
<countDirection value="1" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value = "%date %-5level [%logger] %message%newline%exception"/>

On first run of my application the appender rolls the log files on size. It created 3 log
files myFile_d.log.0, myFile_d, myFile_d.log.2.  Each log file was around 5KB before getting

When I ran the application again, this time instead of creating a new log file myFile_d.log.3,
Log4Net started overwriting the second log file that was generated earlier (that is myFile_d.log.1
was overwritten). It then proceeded to overwrite myFile_d.log.2.

I updated the config and included <maxSizeRollBackups value="-1" />. This time log files
were rolled without any overwriting of existing files.

A similar scenario described in this issue tracker - LOG4NET-378. The bug has been closed
with resolution fixed in v1.2.12.

I would appreciate it if somebody could confirm the following points
1. What is the default value of maxSizeRollBackups if it is not mentioned in the config
file. I could not find this in documentation for this property.

2. For the scenario that I described is expected to include maxSizeRollBackups=-1 in the
config file?

Thanks and Regards,

Mohkam Singh
View raw message