spring-boot 2.7.2
As stated in the docs at https://docs.spring.io/spring-boot/docs/2.7.2/reference/html/features.html#features.logging.file-rotation the log file rotates on a per day basis and when it reaches 10MB.
This is working fine when configured in application.yaml
logging:
file:
name: my/path/application.log
However this feature stops working when the log file is configured by the environment variable LOG_FILE
LOG_FILE=my/path/application.log
We would expect the same (rotation) behaviour in both cases since the environment variable is the yaml equivalent according to https://docs.spring.io/spring-boot/docs/2.7.2/reference/html/features.html#features.logging.custom-log-configuration.
Comment From: quaff
Are you missing _NAME suffix?
Comment From: snicoll
That looks like an oversight in the documentation to me. Can you try with LOG_FILE_NAME as @quaff suggests?
Comment From: philwebb
I think the documentation might be a little confusing in this area. The logging.file.name property is transferred to a system property named LOG_FILE so that it can be referenced in logging configuration files (e.g. logback.xml). You can find the code in the LogFile class.
It looks like the transfer happens regardless of any existing system property.
You could try setting a LOGGING_FILE_NAME environment variable. I think that will map to logging.file.name and then get transferred to LOG_FILE and be picked up by Logback/Log4j.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: fjakop
Thanks for the input, I verified the suggested solution using LOGGING_FILE_NAME, this works and is fine for me.
Comment From: wilkinsona
Let's see if we can clarify the documentation. The table shows how properties in the Spring environment are transferred to system properties but, judging by this issue, it's easy to misinterpret the "System Property" column as environment variables as they're in UPPER_CASE.
Comment From: vivganes
I am willing to take this and work on it. Given that there is a confusion between System property and the Environment variables, would it be good if i add a column with title Environment variable and write the env variables that need to be set for each property in the table?
Comment From: wilkinsona
Thanks for the offer, @vivganes. I'm not really sure how best to fix this. Unfortunately, I don't think another column will help overall. Due to the limited width in the documentation, I think an extra column will make the table harder to read.