Right now I am rotating logs using log4j2 if it reaches 2000MB and time based i.e. every hour with following logic:-
<RollingRandomAccessFile name="test"
fileName="${sys:log4j.logPath}/testlog" filePattern="${sys:log4j.logPath}/test-%d{yyyy-MM-dd-HH}-%i.log.gz">
<PatternLayout>
<Pattern>%d{ISO8601} %m%n</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="1990 MB" />
<TimeBasedTriggeringPolicy />
</Policies>
</RollingRandomAccessFile>
I also want to rotate logs when server shutdown. what configuration I have to add to the following ?
I have used OnStartupTriggeringPolicy to rotate logs on shutdown. But logs gets rotated after made a single request with server restart.
But I want my logs rotated when server shutdown. Is there a way to do it ?