简体   繁体   English

如何在春季以编程方式加载多个log4j xml文件而不使用xml配置

[英]How to load multiple log4j xml files programatically in spring without using xml configuration

I tried using 我尝试使用

Log4jConfigurer.initLogging(firstFile,6000);
Log4jConfigurer.initLogging(nextFile,6000);

but the second file overrides the configuration of first 但是第二个文件将覆盖第一个文件的配置

Programatically, you can merge 2 or more XML files into a single XML, and load it into Log4j. 通过编程,您可以将2个或更多XML文件合并为一个XML,然后将其加载到Log4j。

Also, Log4Configurer.initLogging() is deprecated, but there is another way: - DOMConfigurator.configure(Element element); 另外,不赞成使用Log4Configurer.initLogging(),但还有另一种方法:-DOMConfigurator.configure(Element element);

Using JDom or some other library, you can load/parse your two XML files, merge them to get a single XML Element, and pass it to the above method. 使用JDom或其他一些库,您可以加载/解析两个XML文件,合并它们以获得单个XML元素,然后将其传递给上述方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM