You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Paul Benedict <pb...@apache.org> on 2014/11/03 22:38:41 UTC

Re: log4j2.xml in EAR

Well I have the classes loading now. I still can't find my log4j2.xml but
at least the "api" and "core" libraries are being exposed to my application.

Okay, so to test this, make sure your "api" and "core" libraries are set to
"provided" scope in Maven. You don't want them already bundled; we want to
use the single copy installed in Wildfly.

My module file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="org.apache.log4j2">
    <resources>
        <resource-root path="log4j-api-2.1.jar"/>
        <resource-root path="log4j-core-2.1.jar"/>
    </resources>
    <dependencies>
        <module name="javaee.api" />
    </dependencies>
</module>

It seems "core" is dependent upon JMX and other EE APIs; so I had to
include a dependency. We can probably figure out which EE modules are
really needed (and slim down), but I don't have the time to prune -- so I
included everything EE.

Next was my jboss-deployment-structure.xml. I have to export the log4j
libraries so my EJB modules can see them:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
  <deployment>
    <dependencies>
      <module name="org.apache.log4j2" export="true" />
      </module>
    </dependencies>
  </deployment>
</jboss-deployment-structure>

This is where my JBoss/Wildfly knowledge fails me. I don't know why I need
export="true" but I do.

So the only thing left now is to find the log4j2.xml file. Stay tuned.

Cheers,
Paul