How to force log4net to store only the last X days of logs?

I want log4net to keep talking about 10-day log files, as there are an unlimited number of them that will eventually eat up my disk space. I thought I could do this by setting

<maxSizeRollBackups value="10" />

on my RollingFileAppender but no dice. How to do it?

+3
source share
2 answers

Take a look at this similar post for answers.

Make sure you do not copy logs by date according to the SDK :

The maximum number of backup files when switching to date / time boundaries is not supported.

+7

.

, ?

<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logfile" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<datePattern value="yyyyMMdd" />
<maxSizeRollBackups value="10" />
<layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>

0

Source: https://habr.com/ru/post/1712504/


All Articles