简体   繁体   English

通过外部库log4j.xml覆盖log4j.xml配置

[英]Override log4j.xml configuration over external libraries log4j.xml

Since I added a external jar file to my project, the log4j configuration is being picked up from the log4j.xml which is inside the external jar file. 由于我向项目添加了外部jar文件,因此将从外部jar文件内部的log4j.xml中获取log4j配置。 The log4j.xml configuration within my application is not getting applied. 我的应用程序中的log4j.xml配置未得到应用。

Is there a way to override the log4j.xml configuration so that my applications log4j.xml gets picked? 有没有一种方法可以覆盖log4j.xml配置,以便选择我的应用程序log4j.xml?

EAR Structure : 耳结构:

\\lib\\externalJar\\log4j.xml \\ lib \\ externalJar \\ log4j.xml

\\appweb.war\\WEB-INF\\classes\\log4j.xml \\ appweb.war \\ WEB-INF \\ classes \\ log4j.xml

I can see the warning in the log file as : log4j:WARN No appenders could be found for logger. 我可以在日志文件中看到警告:log4j:WARN找不到记录器的附加程序。

Thanks in advance 提前致谢

If you bundle the the required log4j jar file into your webapp's WEB-INF/lib directory, then the webapps's classloader will load the log4j classes, and you can use your own configuration. 如果将所需的log4j jar文件捆绑到webapp的WEB-INF / lib目录中,则webapps的类加载器将加载log4j类,并且您可以使用自己的配置。 This will be separate from the instance of log4j loaded by the ear classloader, and used by the external jar you added. 这将与耳类加载器加载的log4j实例分开,并由您添加的外部jar使用。

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

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