How to enable native log4j with Jboss AS 7.1

I tried several options. But nothing worked for me. I used to use the same log4j.xml (simple shared config) with Tomcat 6.7, and I was able to control the root logging and application logging with the update log4j.xml. When I deploy the same project with JBoss AS 7.1, it only gives me INFO level logging, and my log4j.xml does not work at all. Sometimes this can be fixed by updating some configuration files inside the JBoss server, but I like to know if it has a portable way to do this or something like that. If this is a bug or something with JBoss AS 7.1, I still like to know about a quick fix. I have not worked with JBoss before.

Thanks!

+4
source share
1 answer

I had this problem and it was solved in the following way:
use your own jar of log4j instead of the one provided by jboss. Do this by excluding org.apache.log4j jar module from the jboss application (exclude it in jboss-deployment-structure.xml) and add your own jar4j jar file to the lib folder of the .ear package. Now put log4j.xml in the root folder of your module.
By this method, you have full control over log4j (e.g. stand-alone applications).
Let me know if you still need help.

Example jboss-deployment-structure.xml for log4j.jar exception:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> <deployment> <exclusions> <module name="org.apache.log4j" slot="main"/> </exclusions> </deployment> <sub-deployment name="MyEjb.jar"> <exclusions> <module name="org.apache.log4j"/> </exclusions> </sub-deployment> 

+2
source

Source: https://habr.com/ru/post/1486495/


All Articles