I am trying to create new log files on an hourly basis. I am using TimeBasedTriggerringPolicy
of lo4j2 in RollingFileAppender
. Below is the sample xml configuration code i have taken from log4j2 official site.
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="MyApp" packages="">
<Appenders>
<RollingFile name ="RollingFile"
fileName ="logs/app.log"
filePattern ="logs/$${date:yyyy-MM}/app-%d{yyyy-MM-dd-HH}-%i.log.gz">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
</PatternLayout>
<Policies>
<!-- *** -->
<TimeBasedTriggeringPolicy interval="1"
modulate="true"/>
<!-- *** -->
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="RollingFile"/>
</Root>
</Loggers>
</Configuration>
In the interval attribute I have set 1 which signifies 1 hour. But still my file does not roll every 1 hour.
Please help me find any mistake.
Note : I have included beta9 of log4j2 (which is the latest)