本文整理汇总了Java中org.apache.log4j.xml.DOMConfigurator.doConfigure方法的典型用法代码示例。如果您正苦于以下问题:Java DOMConfigurator.doConfigure方法的具体用法?Java DOMConfigurator.doConfigure怎么用?Java DOMConfigurator.doConfigure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.log4j.xml.DOMConfigurator
的用法示例。
在下文中一共展示了DOMConfigurator.doConfigure方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadLog4JConfig
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
private static void loadLog4JConfig(ServletContext servletContext,
Hierarchy hierarchy) throws ServletException {
try {
String log4jFile = "/WEB-INF/log4j.xml";
InputStream log4JConfig = servletContext.getResourceAsStream(log4jFile);
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(log4JConfig);
DOMConfigurator conf = new DOMConfigurator();
conf.doConfigure(doc.getDocumentElement(), hierarchy);
} catch (Exception e) {
throw new ServletException(e);
}
}
示例2: configure
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
/**
* Static method to change the Log4j config globally.
* @param xmlConfig The text of a Log4j config file.
*/
public static void configure(String xmlConfig) {
DOMConfigurator configurator = new DOMConfigurator();
StringReader sr = new StringReader(xmlConfig);
configurator.doConfigure(sr, LogManager.getLoggerRepository());
}
示例3: configure
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
/**
* Static method to change the Log4j config globally.
* @param xmlConfig The text of a Log4j config file.
*/
public static void configure(String xmlConfig) {
DOMConfigurator configurator = new DOMConfigurator();
StringReader sr = new StringReader(xmlConfig.trim());
configurator.doConfigure(sr, LogManager.getLoggerRepository());
}