开发者

Difference between configuring log4j using configure and doConfigure

开发者 https://www.devze.com 2023-04-12 18:55 出处:网络
While searching for a way to reload the logging configuration for log4j I realized that in our current code we were using:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号