I performed asynchronous logging using log4j 2, but now I need to change the log file name every hour, for example 2015-11-19 / log-12.00.log, 2015-11-19 / log-13.00, etc. (The souls that I found didn’t work, maybe I did something wrong).
I have the following log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<RandomAccessFile name="RandomAccessFile" fileName="async.log" immediateFlush="false" append="true">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] %m %ex%n</Pattern>
</PatternLayout>
</RandomAccessFile>
</Appenders>
<Loggers>
<Root level="info" includeLocation="false">
<AppenderRef ref="RandomAccessFile"/>
</Root>
</Loggers>
</Configuration>
How to achieve this?
source
share