Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Logging Level in Spring Boot via Environment Variable

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 as I'm running on Cloud Foundry and want to pick up changes without a deploy (but after the app has restarted, or restaged to be more precise).

I've tried setting env vars like LOGGING_LEVEL_ORG_SPRINGFRAMEWORK=TRACE but that has no effect. Putting logging.level.org.springframework: TRACE in application.properties does work though.

like image 832
EngineerBetter_DJ Avatar asked Dec 09 '15 14:12

EngineerBetter_DJ


People also ask

How do I change the logger level in spring boot?

In Settings -> Config Vars set logging. level.com. yourpackage to the desired level (INFO, ERROR, DEBUG).

How do you configure spring boot logging?

Spring Boot has a LoggingSystem abstraction that attempts to configure logging based on the content of the classpath. If Logback is available, it is the first choice. You can also set the location of a file to which to write the log (in addition to the console) by using "logging. file".

Can you control logging with spring boot How?

Spring Boot's default configurations provides a support for the use of Java Util Logging, Log4j2, and Logback. Using these, we can configure the console logging as well as file logging. If you are using Spring Boot Starters, Logback will provide a good support for logging.


1 Answers

This is just an idea, but did you try setting

_JAVA_OPTIONS=-Dlogging.level.org.springframework=TRACE?

Theoretically, this way -Dlogging.level.org.springframework=TRACE will be passed as default JVM argument and should affect every JVM instance in your environment.

like image 139
Timekiller Avatar answered Sep 19 '22 21:09

Timekiller