Externalize Log4j configuration

By default, Log4j looks for a configuration file named log4j.properties or log4j.xml under classes folder of your webapp.

Sometimes you may need externalize Log4j configuration out of your application archive. As you know, it supports two kind of configuration file: *.properties and *.xml. Below is showed how to tell to Log4j which configuration file load.

Properties configuration

PropertyConfigurator.configure("log4j.properties");

XML configuration

DOMConfigurator.configure("log4j.xml");

References

http://www.javabeat.net/2008/07/baisc-steps-to-configure-log4j-using-xml-and-properties-file/

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This site contains free tutorial. Please donate to support