The issue
When the app is (re)started, then even though its configuration file contains "quarkus.log.file.rotation.rotate-on-boot=true" the log files are not rotated.
(we're using Quarkus release: 1.4.1.Final )
Expected behavior
As the documentation says the parameter "rotate-on-boot" should assure rotation of log files "on server initialization".
Actual behavior
Log files do rotate every minute when I put suffix "HH_mm", but I expect also the desired rotation on boot, i.e. to have always new empty log files when the app is started.
To Reproduce
Steps to reproduce the behavior:
Same in Dev-Mode, 1.4.2.Final.
cc @harthorst & @tkalmar
It seems all the logging properties are just forwarded to https://github.com/dmlloyd/jboss-logmanager-embedded
So maybe this is something for @dmlloyd?
It seems that I have found a way how to make it work, it's generally 脿 la scenario "when you want to make function A work, you need to 'intuitively' turn on function B" :
How to:
When you put "quarkus.log.file.rotation.max-file-size" into your propeties file, then the rotate on boot starts working, not impacted by the value of "max-file-size" itself.
Sample:
If you put e.g. "quarkus.log.file.rotation.max-file-size=10M" into the config file, then your app will start creating new empty log file each time when you restart it, even if current size of log file was less than 10M.
/cc @jamezp is this consistent with how the handlers are expected to work?
It should be the max-backup-index that triggers it to rotate. What triggers it is the setFile() method which assumes that the handler is fully reconfigured on "boot".
@brundipub what is the full handler configuration? I can try to duplicate it here so I can make sure it's not the handler itself that's the issue.
Tested again in our 1.4.1.Final:
With this config it DOESN'T rotate on boot:
quarkus.log.level=WARN
quarkus.log.category."io.quarkus".level=INFO
quarkus.log.console.enable=true
quarkus.log.console.format=%d{HH:mm:ss} %-5p [%c{2.}] (trace-id:%X{traceId}) (%t/%X{jobs_count}) %s%e%n
quarkus.log.file.enable=true
quarkus.log.file.level=ERROR
quarkus.log.file.path=/tmp/simulator.log
quarkus.log.file.format=%d{HH:mm:ss} %-5p [%c{2.}] (trace-id:%X{traceId}) (%t/%X{jobs_count}) %s%e%n
quarkus.log.file.rotation.rotate-on-boot=true
quarkus.log.file.rotation.max-backup-index=50
quarkus.log.file.rotation.file-suffix=yyyy-MM-dd
quarkus.log.handler.file."LOAD_TEST_LOG".path=/tmp/load_test.log
quarkus.log.handler.file."LOAD_TEST_LOG".enable=true
quarkus.log.handler.file."LOAD_TEST_LOG".format=%d{HH:mm:ss} %-5p [%c{2.}] (%t/%X{jobs_count}) %s%e%n
quarkus.log.handler.file."LOAD_TEST_LOG".rotation.rotate-on-boot=true
quarkus.log.handler.file."LOAD_TEST_LOG".rotation.max-backup-index=50
quarkus.log.handler.file."LOAD_TEST_LOG".rotation.file-suffix=yyyy-MM-dd
quarkus.log.category."LOAD_TEST".handlers=LOAD_TEST_LOG
When we uncomment the max-file-size lines, then rotate on boot starts working.
This looks like it's an issue with how Quarkus determines which handler to configure.
https://github.com/quarkusio/quarkus/blob/c12a09d83a010c035d85b1d941245a395636872b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java#L274-L290
It only configures a SizeRotatingFileHandler or PeriodicSizeRotatingFileHandler if the max-file-size is set. In this configuration case it's using a PeriodicRotatingFileHandler which does not have a rotate-on-boot option.
Most helpful comment
This looks like it's an issue with how Quarkus determines which handler to configure.
https://github.com/quarkusio/quarkus/blob/c12a09d83a010c035d85b1d941245a395636872b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java#L274-L290
It only configures a
SizeRotatingFileHandlerorPeriodicSizeRotatingFileHandlerif themax-file-sizeis set. In this configuration case it's using aPeriodicRotatingFileHandlerwhich does not have arotate-on-bootoption.