I am making a game with LWJGL3 and am using log4j2 for logging. I am trying to setup my logger which works however each time the program is executed it just overwrites the lastest.log file instead of compressing it and then overwriting latest.log. I tried setting the minSize of the OnStartupTriggeringPolicy because it defaults to 1 and my file size is currently extremely small but that didn't help. Does anyone have any idea on how to get this working.
log4j2.xml
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss} [%level] [%t] - %msg%n" />
</Console>
<RollingFile name="RollingFile" filename="log/latest.log"
filePattern="${logPath}/%d{YYYYMMddHHmmss}.log.gz"
append="false">
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss} [%level] [%t] - %msg%n" />
<Policies>
<OnStartupTriggeringPolicy minSize="0"/>
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
<DefaultRolloverStrategy max="8"/>
</RollingFile>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console" />
<AppenderRef ref="RollingFile" />
</Root>
</Loggers>
</Configuration>
Have you tried adding:
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
Here is an example of log4j2 configuration that I currently used in my projects.
<RollingFile name="file-log" fileName="${log-path}/autodeployer.log"
filePattern="${log-path}/autodeployer-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<Pattern>${LOG_PATTERN}</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<SizeBasedTriggeringPolicy size="50MB"/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingFile>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.