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:
- I've added log4j2-api.jar as a system module to Wildfly (system/layers/base/org/apache/log4j2/main) with a simple module.xml.
- I've taken the code from https://github.com/jboss-logging/log4j2-jboss-logmanager, built a JAR, and added that as a system module to Wildfly (system/layers/base/org/jboss/log4j2/logmanager/main), with a module.xml that defines a provided service:
<provides>
<service name="org.apache.logging.log4j.spi.Provider">
<with-class name="org.jboss.logmanager.log4j.JBossProvider" />
</service>
</provides>
- I've added org.apache.log4j2 and org.jboss.log4j2.logmanager as dependencies to the org.jboss.logmanager module, stating
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>