I've configured a RollingRandomAccessFileAppender
with only the OnStartupTriggeringPolicy
set, but when I set the max
attribute of the DefaultRolloverStrategy
to some number, the logs keep generating past that amount indefinitely.
Here's my log4j2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console"
target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
<RollingRandomAccessFile name ="RollingRAF"
fileName ="logs/app.log"
filePattern ="logs/app-%d{[email protected]}.log">
<PatternLayout>
<Pattern>%d %p %c{1.} %m%n</Pattern>
</PatternLayout>
<Policies>
<OnStartupTriggeringPolicy/>
</Policies>
<DefaultRolloverStrategy max="5"/>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<Logger name="myLogger"
level="warn">
<AppenderRef ref="RollingRAF"/>
</Logger>
<Root level="error">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
Is it because I don't have an iterator in my name pattern?
Is it because my file name precision is set to seconds?
Is it because I only have the OnStartupTriggeringPolicy
set?
Or what's going on here?
My goal here was to set up a rolling configuration that will log the last 5 application runs.
<TimeBasedTriggeringPolicy />
since you are using date in the name pattern? – Sphalerite