Difference between configuring log4j using configure and doConfigure
While searching for a way to reload the logging configuration for log4j I realized that in our current code we were using:
input = new FileInputStream(newFileName);
new DOMConfigurator().doConfigure(input,LogManager.getLoggerRepository());
To read the configuration file during startup of our webapplication.
开发者_如何学运维Looking at the API I see the method configure (and also configureAndWatch, which is what I want to do). What is the difference between using the above compared to:
DOMConfigurator.configure(newFileName);
Edit: Note that newFileName is a String with the path to the file.
The configure method just creates a new DomConfigurator instance and calls doConfigure on it:
public static void configure (Element element) {
DOMConfigurator configurator = new DOMConfigurator();
configurator.doConfigure(element, LogManager.getLoggerRepository());
}
The source code for DomConfigurator can e.g. be found at Docjar
精彩评论