I have a log file named app.log. When it rolls over (I'm setting it to every minute just for testing purposes), I would like it to be renamed to app-YYYY-MM-dd_HH-mm.log
but it's not working. Below is my log4j settings:
log4j.appender.myLog=org.apache.log4j.RollingFileAppender
log4j.appender.myLog.rollingPolicy=TimeBasedRollingPolicy
log4j.appender.myLog.File=logs/app.log
log4j.appender.myLog.rollingPolicy.FileNamePattern=logs/app-%d{yyyy-MM-dd_HH-mm}.log
log4j.appender.myLog.Append=true
log4j.appender.myLog.layout=org.apache.log4j.PatternLayout
log4j.appender.myLog.layout.ConversionPattern=%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n
Does anyone know what's the problem? During the rollover, it just renames the file into app.log.1
.
According to the log4j wiki:
Note that TimeBasedRollingPolicy can only be configured with xml, not log4j.properties
The API doesn't mention that, but perhaps that's the problem?
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