I would like to externalize the log level in logback-spring.xml
as below,
<root level="${logback.loglevel}">
<appender-ref ref="CONSOLE"/>
</root>
In my application.yml
file I have:
logback:
loglevel: WARN
But this value is not picked from Logback XML and runs with DEBUG
level instead. If I hard coded the value there as WARN
only it runs as WARN
level.
It seems that the type of configuration externalization you are trying to achieve is based on the Spring application.yml
configuration files.
If that is the case, Spring Boot provides out of the box different configuration properties you can use to define the appropriate logging level, no matter the underlying logging library implementation you are using.
You can provide the appropriate configuration in your different application.properties
or application.yaml
, something like:
logging:
level:
root: "warn"
org.springframework.web: "debug"
org.hibernate: "error"
Be aware that using a custom logback-spring.xml
file is unnecessary.
Please, consider review the aforementioned documentation if you need more information.