简体   繁体   中英

log4j : reconfigure twice

I want when my app starts to configure log4j with some default configuration. Once the other configuration (non-log4j) is parsed I get the real file-path to the real log4j configuration. Now I can fully configure log4j.

How would you do that. (java) ?

Also I prefer to use .json config file, if it matters.

Based on the answers to this question , it seems to be pretty complicated with log4j2 (which is what I assume you're using seeing as you're talking about using a JSON configuration file, which didn't exist in log4j 1.x as far as I know).

If you're willing to use an XML or properties log4j configuration and also step down to log4j 1.x, you can use PropertyConfigurator.configure(String) or DOMConfigurator.configure(String) depending on if you're using a properties or XML configuration file.

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