2

In order to change log level, how env variable should be named for camel-cased class name?

For example I have my.package.MyClass:

export LOGGING_LEVEL_MY_PACKAGE=DEBUG works for the whole package well;

export LOGGING_LEVEL_MY_PACKAGE_MYCLASS=DEBUG does no effect

export LOGGING_LEVEL_MY_PACKAGE_MY_CLASS=DEBUG does no effect

Max Farsikov
  • 2,451
  • 19
  • 25
  • Does this answer your question? [Set Logging Level in Spring Boot via Environment Variable](https://stackoverflow.com/questions/34181094/set-logging-level-in-spring-boot-via-environment-variable) – sp00m Jun 21 '22 at 13:45
  • Quoting the [docs](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.logging.log-levels): _The above approach will only work for package level logging. Since relaxed binding always converts environment variables to lowercase, it is not possible to configure logging for an individual class in this way. If you need to configure logging for a class, you can use [the `SPRING_APPLICATION_JSON`](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.external-config.application-json) variable._ – sp00m Jun 21 '22 at 13:46
  • @sp00m Thanks! Could you please put it to answer, I will accept it. Also, it would be nice to add that for this case: `export SPRING_APPLICATION_JSON='{"logging.level.my.package.MyClass": "DEBUG"}'` would work – Max Farsikov Jun 21 '22 at 14:06

1 Answers1

2

Kudos to @sp00m!

export SPRING_APPLICATION_JSON='{"logging.level.my.package.MyClass": "DEBUG"}' solved the problem. Reference to the Spring documentation

Max Farsikov
  • 2,451
  • 19
  • 25