This question already has an answer here:
- Log4Net: set Max backup files on RollingFileAppender with rolling Date 8 answers
I am using log4net RollingFileAppender in a windows service program written in C#. The number and size of files in logs directory is growing too fast, need cleanup. The configuration is below:
<appender name="Rolling Log" type="log4net.Appender.RollingFileAppender">
<file value="..\logs\MyProgram.%cs{instanceName}.log" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<datePattern value=".yyyy-MM-dd.lo\g" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="150MB" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%-5level] %property{remoteUser} [%threadIdentity] %type{1}.%method - %message%newline%exception" />
</layout>
I only want to keep 30 days of logs. How can I configure log4net to delete the logs automatically? If not available through log4net, what solutions would I have?
Thank you in advance.