Set Logging Level in Spring Boot via Environment Variable

后端 未结 10 1059
刺人心
刺人心 2020-12-23 08:57

Should it be possible to set logging levels through environment variables alone in a Spring Boot application?

I don\'t want to use application.properties

10条回答
  •  [愿得一人]
    2020-12-23 09:57

    I also tried to set logging level via environment variable but as already mentioned it is not possible by using environment variable with upper case name, eg. LOGGING_LEVEL_ORG_SPRINGFRAMEWORK=DEBUG. I also didn't want to do it via application.properties or _JAVA_OPTIONS.

    After digging into class org.springframework.boot.logging.LoggingApplicationListener I've checked that spring boot tries to set logging level DEBUG to ORG_SPRINGFRAMEWORK package which is not real package name. So conclusion is that you can use environment variable to set logging level but it needs to be in the form: LOGGING_LEVEL_org.springframework=DEBUG or logging.level.org.springframework=DEBUG

    Tested on spring boot 1.5.3

提交回复
热议问题