简体   繁体   中英

How to switch between log4j configuration files at runtime with a condition

I have two different log4j.properties files. One is for production and the other one is for sandbox. Normally, application uses log4j.properties. But for sandbox version (by using a condition) I want that application should use a properties file which is created by me and named as sandbox-log4j.properties. Only difference between them is a log tracking line is added to sandbox version.

How could I make a switch between two files by using a conditin in a java file?

I found the answer. @Michael's suggestion on JVM helped me to handle the problem. I use Elastic Beanstalk and its JVM options field on Configuration provided to separate log4j.properties files. Setting JVM options to -Dlog4j.configuration=sandbox-log4j.properties is enough for solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM