Reputation: 431
I have log4Net set up with the following config settings in a web service web.config file:
<log4net>
<!-- RollingFile is set to be a File Appender -->
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="c:\temp\Sync.log" />
<appendToFile value="true" />
<maximumFileSize value="50MB" />
<maxSizeRollBackups value="10" />
<datePattern value="yyyyMMdd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level %-50logger - %message%newline%newline" />
</layout>
</appender>
<!-- Set root logger level to DEBUG to have all log -->
<root>
<level value="INFO" />
<appender-ref ref="RollingFile" />
</root>
The issue I am having is when I look in temp I see 17 files Sync.Log Sync.log20180424.log (other sync files with dates) ... the last one being Sync.log20180405
I am confused as to why it is not removing the ones beyond 10 days as stated by the maxSizeRollBackups. I know that by default the is rollingStyle = composite. With my current config, how would it behave if I let it go? And as a second - what am I missing in my current settings.
Thanks. I know there are similar questions out there but in reading them I feel like I am still missing something.
Upvotes: 1
Views: 866
Reputation: 431
It turns out that what I was trying to do is not possible.
As stated in other places:
A maximum number of backup files when rolling on date/time boundaries is not supported.
Because of this, I took the date portion out so that the backups roll by size only. After doing that I did not have the same issues. I don't like the file name as much but it is still easy enough to track them based on their file properties having the date last edited.
Upvotes: 2