We are using Log4j2.3 version for logging and using xml configuration. Here it is like -
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<RollingFile name="testingAppender" fileName="Test.log"
filePattern="logs/Test.log.%i">
<PatternLayout>
<pattern>[%-5p] %d{dd MMM yyyy HH:mm:ss} - %m %n</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="5 MB" />
</Policies>
<DefaultRolloverStrategy max="10" />
</RollingFile>
</Appenders>
<Loggers>
<Logger name="testingLogger" level="debug">
<AppenderRef ref="testingAppender" level="debug" />
</Logger>
</Loggers>
</Configuration>
Log files are rotating fine. But the LATEST log file is having highest rolling number Example - Test.log7, where it should be Test.log0. Log file numbers are rotating in reverse order.
Need help in this.
This is not incorrect but the default behavior. To get your intended behavior, try setting fileIndex
attribute min
.
<DefaultRolloverStrategy max="10" fileIndex="min" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With