我的EAR中的WAR不会正确加载log4j2,但是JAR会加载它
我有这个瘦骨war E的EAR文件。 它应该包含在WildFly 8.2.0.Final应用程序服务器中。
- lib
- log4j-api-2.1.jar
- log4j-core-2.1.jar
- META-INF
- application.xml
- jboss-app.xml
- log4j2.xml
- MANIFEST.MF
- my-ejb.jar
- my-web.war (skinny war)
- META-INF
- MANIFEST.MF
- WEB-INF
- classes
- ...
- lib (empty since skinny war)
- index.html
当我第一次从my-web.war
开始登录时,我一直得到这个消息: 2015-03-04 11:04:22,806 ERROR [stderr] (default task-23) ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
2015-03-04 11:04:22,806 ERROR [stderr] (default task-23) ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
2015-03-04 11:04:22,806 ERROR [stderr] (default task-23) ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
并且没有消息添加到我的日志文件中。
但是,当我从my-ejb.jar
开始记录时,我完全没有问题,并且随后从my-web.war
记录也正常工作。
如何在我的EAR文件中正确使用/配置log4j2,以便我不必关心我的ejb文件是否先被调用?
文件,请求:
我-ejb.jar / META-INF / MANIFEST.MF:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: Olivier
Class-Path: lib/log4j-api-2.1.jar lib/guava-18.0.jar lib/log4j-core-2.
1.jar lib/log4j-web-2.1.jar
Created-By: Apache Maven 3.2.3
Build-Jdk: 1.8.0_25
我-的web.war / META-INF / MANIFEST.MF
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: Olivier
Class-Path: lib/log4j-api-2.1.jar lib/guava-18.0.jar lib/log4j-core-2.
1.jar lib/log4j-web-2.1.jar
Created-By: Apache Maven 3.2.3
Build-Jdk: 1.8.0_25
log4j2.xml
文件必须位于类路径中才能找到。
尝试把它放在这里:
my-web.war
WEB-INF
classes
log4j2.xml
my-ejb.jar MANIFEST.MF是否包含相对于log4j jar的类路径? 如果您想使用自己的log4j配置,请将文件log4j2.xml放在耳朵的根目录下,并将jboss-app.xml放置到耳朵的META-INF文件夹中,并使用以下内容:
<jboss-app>
<loader-repository>
org.myapp:loader=MyClassLoader
<loader-repository-config>
java2ParentDelegation=false
</loader-repository-config>
</loader-repository>
</jboss-app>
链接地址: http://www.djcxy.com/p/82667.html
上一篇: The WAR in my EAR doesn't load log4j2 properly but the JAR does