Log4Net: set Max backup files on RollingFileAppender with rolling Date

Ricky Supit picture Ricky Supit · Sep 18, 2008 · Viewed 67.6k times · Source

I have the following configuration, but I have not able to find any documentation on how to set a maximum backup files on date rolling style. I know that you can do this with size rolling style by using the maxSizeRollBackups.

<appender name="AppLogFileAppender" type="log4net.Appender.RollingFileAppender">
    <file value="mylog.log" />
    <appendToFile value="true" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <rollingStyle value="Date" />
    <datePattern value=".yyMMdd.'log'" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%d %-5p %c - %m%n"  />
    </layout>
</appender>

Answer

Charley Rathkopf picture Charley Rathkopf · Sep 19, 2008

You can't.

from log4net SDK Reference
RollingFileAppender Class

CAUTION

A maximum number of backup files when rolling on date/time boundaries is not supported.