Search code examples
wildflylog4j2

wildfly log4j2 ClassNotFoundException: org.apache.commons.logging.Log


trying to configure wildfly to use log4j2. Following the instructions here:

http://www.mastertheboss.com/jbossas/jboss-log/how-to-use-log4j2-in-your-wildfly-applications/

Whenever org.apache.commons.logging is excluded:

 <exclusions>
        <module name="org.apache.logging.log4j.api"/>
        <module name="org.apache.log4j" />
        <module name="org.apache.commons.logging"/>         
</exclusions>

or the logging subsystem is excluded as in:

<exclude-subsystems>
    <subsystem name="logging"/>
</exclude-subsystems>        

I end up with:

undertow-deployment: java.lang.NoClassDefFoundError: org/apache/commons/logging/Log

If I don't exclude the org.apache.commons.logging and/or the logging subsystem, I get no errors, but the system is not reading my log4j2.xml file either.


Solution

  • Thanks to James Perkins for helping me figure this out. I had libraries that were referencing commons-logging and also log4j1. The solution is to include log4j1 and commons-logging jars in the deployment while at the same time, excluding the 3 modules above in jboss-deployment-structure.xml.