-
1. Re: How to add log4j2 to Wildfly modules?
jamezp Apr 7, 2014 1:57 PM (in response to niksa.baldun)I don't know how log4j2 finds it's implementation, but you might need to add services="import" to the org.apache.log4j2 module. Also were it me I'd probably just put the core library in the same module directory as the API and just add the resource to the org.apache.log4j2 module.
--
James R. Perkins
-
2. Re: How to add log4j2 to Wildfly modules?
niksa.baldun Apr 7, 2014 3:04 PM (in response to jamezp)Thanks for the reply.
The log4j2 API locates logging implementations by searching for META-INF/log4j-provider.properties file in the classpath. The log4j-core jar has that file inside it.
About your second suggestion, I already tried it and it didn't work (I get the same error message).
About your first suggestion, where exactly do I put services="import"?
-
3. Re: Re: How to add log4j2 to Wildfly modules?
jamezp Apr 7, 2014 3:27 PM (in response to niksa.baldun)Ah, in that case you need to explicitly import the path. You should end up with something like:
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.1" name="org.apache.log4j2"> <resources> <resource-root path="log4j-api-2.0-beta9.jar"/> </resources> <dependencies> <module name="org.apache.log4j2.core"> <imports> <include path="META-INF"/> </imports> </module> </dependencies> </module>
--
James R. Perkins
-
4. Re: Re: Re: How to add log4j2 to Wildfly modules?
niksa.baldun Apr 7, 2014 5:00 PM (in response to jamezp)Thanks, man, that is spot on. I also had to add some dependencies to log4j.core. I am including module.xml for future readers.
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.1" name="org.apache.log4j2.core"> <resources> <resource-root path="log4j-core-2.0-beta9.jar"/> </resources> <dependencies> <module name="org.apache.log4j2"/> <module name="com.lmax.disruptor"/> <module name="javax.api"/> <module name="javax.servlet.api"/> </dependencies> </module>
-
5. Re: Re: Re: Re: How to add log4j2 to Wildfly modules?
niksa.baldun Apr 13, 2014 4:01 AM (in response to niksa.baldun)Another note for future readers. This setup worked for some time, and then I suddenly started to receive the same error message again. Obviously, I must have changed something somewhere that influenced log4j2 module, but I could not find out what it is. Finally, I resolved it by putting the same filter in jboss-deployment-structure.xml.
<?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure> <deployment> <exclusions> </exclusions> <dependencies> <module name="org.apache.log4j2.core"> <imports> <include path="META-INF"/> </imports> </module> </dependencies> </deployment> </jboss-deployment-structure>
-
6. Re: How to add log4j2 to Wildfly modules?
jaymz2014 Jan 31, 2017 5:17 AM (in response to niksa.baldun)Hello,
I tried your configuration but i have this error :
Failed to define class org.apache.logging.log4j.core.impl.Log4jContextFactory in Module "org.apache.log4j2.core:main"...
java.lang.NoClassDefFoundError: Failed to link org/apache/logging/log4j/core/impl/Log4jContextFactory (Module "org.apache.log4j2.core:main"...
I can't see what is wrong...
Thank you for you help
-
7. Re: How to add log4j2 to Wildfly modules?
jamezp Feb 2, 2017 12:17 PM (in response to jaymz2014)Could you share your module.xml file(s)? That message definitely looks a bit weird.
--
James R. Perkins