This is a log4j 1.X question. I have code running in a Tomcat servlet engine where I can't control the log4j.properties but I would like to change the logging configuration at runtime. I have found how to do this via PropertyConfigurator, and can update with properties. Is there a way to dynamically get the current configuration in Properties format?
If not available within log4j library is there an external open source library?
Based on your reply to my comment I really like your idea and I can see how it would be very useful. To my knowledge there is no feature provided by log4j 1.X that will dump the current config as a properties file. I'm pretty sure only the deserialization has been implemented - going from properties to objects in memory not vice versa.
Take for example a ConsoleAppender
- if we look at the javadoc there is nothing to indicate that it is serializable or capable of dumping its configuration in any way let alone as properties.
Two options come to mind and they are:
OR
Hope this helps!
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.