I have a command line application in which I have enabled log4j. For now only file logging is added. Now I want that, without restarting or recompiling jar file I should be able to change configuration of log4j.
I read in log4j manual that it can automatically detect changes in config file. So how can I put config file in some separate location and have it's changes reflected in runtime in the application?
There are many ways to do this. They are covered in the log4j configuration guide.
The simplest is to put a log4j.xml on the classpath. Then add the monitorInterval="30" attribute to the opening configuration tag. This tells log4j to check the file for changes every 30 seconds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With