Configure logback log level via environment variables
Mar 14, 2018
0 Comments
If you are running a java application with logback inside a docker container, it may be really useful to interact with logging levels via OS environment variables.
It’s simple as declaring a new variable inside your logback.xml
file and provide a default value as in the Bash shell, using the ":-" operator.
<variable name="CLOUDESIRE_LOG_LEVEL" value="${CLOUDESIRE_LOG_LEVEL:-DEBUG}" />
<logger name="com.cloudesire" level="${CLOUDESIRE_LOG_LEVEL}"/>
Then you can simply run your docker container tuning the log level by passing an appropriate value, e.g.: CLOUDESIRE_LOG_LEVEL=WARN
.
Source: Developers’ Corner Blog