I'm working on a JEE application which uses log4j2 for logging. I'm trying to deploy it on Wildfly 15, but I can't get it to log properly, stating
Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
Here's what I did:
<provides>
<service name="org.apache.logging.log4j.spi.Provider">
<with-class name="org.jboss.logmanager.log4j.JBossProvider" />
</service>
</provides>
services="export"
on the latter.I'm aware of https://issues.redhat.com/browse/WFCORE-482, but I can't seem to draw the right conclusions from it.
Can anyone help or knows how to diagnose further what's going on here?
For full reference, the module.xml for org.jboss.log4j2.logmanager looks like this:
<module xmlns="urn:jboss:module:1.8" name="org.jboss.log4j2.logmanager">
<resources>
<resource-root path="log4j2-jboss-logmanager.jar"/>
</resources>
<dependencies>
<module name="org.apache.log4j2"/>
<module name="org.jboss.logmanager"/>
</dependencies>
<provides>
<service name="org.apache.logging.log4j.spi.Provider">
<with-class name="org.jboss.logmanager.log4j.JBossProvider" />
</service>
</provides>
</module>
…although i've tried both referencing org.jboss.logmanager as a dependency of org.jboss.log4j2.logmanager and the other way around.
The module.xml for org.apache.log4j2 looks like this:
<module xmlns="urn:jboss:module:1.1" name="org.apache.log4j2">
<resources>
<resource-root path="log4j-api.jar"/>
</resources>
</module>
In your org.jboss.log4j2.logmanager
module.xml you don't need that <provides/>
definition. Other than that your module.xml files look correct.
Next you'll need to define both the org.jboss.log4j2.logmanager
and org.apache.log4j2
modules on your deployment. If you're using a jboss-deployment-structure.xml
it would look something like the following for a WAR:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.apache.log4j2"/>
<module name="org.jboss.log4j2.logmanager" export="true"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
One minor note is those should probably live directly under the modules
directory and not the modules/system/layers/base
directory. Though it doesn't break anything that is really meant for modules provided by the server.