I'm using a daily rolling policy with log4j2 with a TimeBasedTriggeringPolicy. The log must roll each day at midnight. I'm using the example except that I have a timezone Europe/Paris.
https://howtodoinjava.com/log4j2/log4j2-rollingfileappender-example/
To enable the daily rolling, log4j2 does not include the DailyRollingFileAppender which was present in earlier log4j. To rollover logs on daily basis, set interval to 1 in TimeBasedTriggeringPolicy.
<RollingFile
name="rollingFile"
fileName="${LOG_DIR}/application.log"
filePattern="${LOG_DIR}/application.%d{dd-MMM}{Europe/Paris}.log.gz"
ignoreExceptions="false">
<PatternLayout>
<Pattern>%d{yyyy-MM-dd HH:mm:ss}{Europe/Paris} %-5p %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1"/>
</Policies>
<DefaultRolloverStrategy max="5" />
</RollingFile>
I'm facing the issue that instead of rolling at midnight Paris Time, it rolls at GMT which is 22:00 on the previous day. I found that issue that could be related : https://issues.apache.org/jira/browse/LOG4J2-1631
On that issue, the reporter seems to report the exact same issue except that he was using a different timezone.