1

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.

1
  • Correct me if I am wrong I am guessing that part of my issue is rollingStyle Date would be what I need to have ?. Which if so, makes me question how it is now (composite).... Would that mean that as I have it set now, in theory would I get an infinite number of files that could fill a drive and all it is doing as I have it is limiting me to have a max of 10 log files a day for infinite number of days??
    – jvoigt
    Commented Apr 26, 2018 at 14:32

1 Answer 1

2

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.