spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Clarify table that shows how logging properties are transferred to system properties

Open fjakop opened this issue 3 years ago • 8 comments
trafficstars

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.

fjakop avatar Aug 24 '22 05:08 fjakop

Are you missing _NAME suffix?

quaff avatar Aug 24 '22 07:08 quaff

That looks like an oversight in the documentation to me. Can you try with LOG_FILE_NAME as @quaff suggests?

snicoll avatar Aug 24 '22 08:08 snicoll

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.

philwebb avatar Aug 25 '22 02:08 philwebb

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.

spring-projects-issues avatar Aug 31 '22 08:08 spring-projects-issues

Thanks for the input, I verified the suggested solution using LOGGING_FILE_NAME, this works and is fine for me.

fjakop avatar Sep 01 '22 05:09 fjakop

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.

wilkinsona avatar Sep 01 '22 08:09 wilkinsona

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?

vivganes avatar Sep 06 '22 12:09 vivganes

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.

wilkinsona avatar Sep 07 '22 06:09 wilkinsona