tags:

views:

635

answers:

1

The problem is, whenever you change the log4j.properties/log4j.xml, you need to restart the tomcat [ or say any other server ]. Is there any workaround of reloading the log4j configuration?

+9  A: 

From http://logging.apache.org/log4j/1.2/faq.html#3.6

Is there a way to get log4j to automatically reload a configuration file if it changes?

Yes. Both the DOMConfigurator and the PropertyConfigurator support automatic reloading through the configureAndWatch method. See the API documentation for more details.

Because the configureAndWatch launches a separate wathdog thread, and because there is no way to stop this thread in log4j 1.2, the configureAndWatch method is unsafe for use in J2EE envrironments where applications are recycled.

Said that, I've successfully used PropertyConfigurator#configureAndWatch method in a JEE environment (Sun One Web Server, not Tomcat).

Guido
You might not notice the problem until your application has been restarted or redeployed a couple of times. Thread or other resource leaks may end up taking down your application server.
Kjetil Ødegaard