Using system environment variables in log4j xml configuration

I tried to do that recently and couldn’t get it to work. What I ended up doing is sending a variable at startup. So say you have an environment variable called $LOG_LEVEL:

<level value="${log_level}" />

and at startup…

java -Dlog_level=$LOG_LEVEL your_app

Leave a Comment