What I want is:
- Maximum of 10 log files, in total
- Each log file, not more than 50MB in size.
Thus the logs folder never grows over (50MB *10 )= 500MB.
But it seems my log4j2 config is not properly done.
What is happening is:
- Logs do roll over after 50 MB
- But there are upto 10 logs kept per day
- Thus there is no limit of number of log files kept in log folder (since for eg, in 2 days, 20 logs of 50mb each have collected)
Here is the config:
<Configuration status="WARN">
<Appenders>
<RollingFile name="RollingFile" fileName="log/my.log" filePattern="log/my-%d{MM-dd-yyyy}-%i.log">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
</PatternLayout>
<Policies>
<OnStartupTriggeringPolicy />
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="50 MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="RollingFile"/>
</Root>
</Loggers>
</Configuration>
What am I doing wrong?