The WAR in my EAR doesn't load log4j2 properly but the JAR does

I have this skinny-war EAR file. It is supposed to be contained in a WildFly 8.2.0.Final application server.

- 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

When I first start logging from my-web.war , I keep getting this message: 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... and no message is added to my log file.

However when I start logging from my-ejb.jar , I have no issue at all and the consequent logging from my-web.war is working fine as well.

How to have log4j2 properly used/configured in my EAR file so that I don't have to care that my ejb file is called first?

Files, as requested:

my-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

my-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

The log4j2.xml file must be in the classpath in order to be found.

Try putting it here:

my-web.war
   WEB-INF
      classes
          log4j2.xml

Does my-ejb.jar MANIFEST.MF contains relative classpath to log4j jars? If you want to use your own log4j configuration, place file log4j2.xml to root of the ear and place jboss-app.xml to META-INF folder of the ear with such content:

<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/82668.html

上一篇: Maje依赖于ejb和war

下一篇: 我的EAR中的WAR不会正确加载log4j2,但是JAR会加载它