I've found a solution, but I'm not sure it's the best one.
It looks like org.apache.log4j has been promoted to a system module, as it has the priority against my own jar, without declaring anything. So, to solve my problem, I decided to exclude the module from my deployment.
I added a WEB-INF/jboss-deployment-structure.xml file with the following content :
<?xml version="1.0" encoding="UTF-8"?>
<module name="org.apache.log4j" />
And now, it works, with my embedded log4j.xml file.
interesting... why do you need to specify exclusions? shouldn't application/war classloader use jar that comes with application first?
It should, but in the latest nightly builds it seems like the server does use the jboss module version unless an exclusion is used, I have a similar problem and it is pretty easy to test out, My problem https://community.jboss.org/thread/194889
I have a similar problem and it is pretty easy to test out, My problem https://community.jboss.org/thread/194889
Would you be able to attach a sample application to quickly test this problem?
Sure I can try, the EAR expects the log4j.properties.xml file directly in the root of "c:\"
Use latest nightly, and deploy ear then go to "localhost:8080/servletLog/hello" to invoke the servlet , then check the server log, the log4j message should be dumped to console and nothing is written to the file defined in the appenders in the specified log4j file.
Just thought i'd point out that even with the approach mentioned here, it will not work if you are using commons-logging; it will not find the intended log4j module. You have to use log4j directly.
You could just exclude the servers version of commons-logging (org.apache.commons.logging) and include it in your deployment.
i found this thread, and some others that resemble this one.
i refer to loading the specific log4j settign from an ear
I still haven't managed to fix it , has anyone yet ?
Maybe this will help you https://docs.jboss.org/author/display/AS71/How+To#HowTo-HowdoIuselog4j.propertiesorlog4j.xmlinsteadofusingtheloggingsubsystemconfiguration%3F. You mainly just need to exclude the servers library and include the log4j library in your deployment.
James R. Perkins
thank, but that doesn't really help,
since i have already tried it and found other occurences that there is a bug in AS 7.1.1 so that you have to put in the deployment structure reference for all components loaded
Finally ,i have made it thru
it turns out that i forgot to mention i use slf4j, which also need to be excluded in order for it to use the binding to the log4j module from the ear/lib directory.
For anyone else that has a similar problem i recomend to remove the jar from the lib dir and make the jboss-deployment-structure file.
When you will have a good deployment structure your deployment will fail with ClassNotFound exception because exclusion of default modules will work and the jar will be missing, then you can add the jar file .
In my case org.apache.log4j was never missed since org.slf4j was loaded from "implicit modules dependency" ()
and it was already binded to the implicit module org.apache.log4j.
Thanks a lot for all your help,
Great news : this strange behaviour (bug ?) has been fixed in JBoss AS 7.1.2 (and in JBoss EAP 6).
It's working on AS 7.1.2, the build-it-yourself version, and only with Log4J. When you put SLF4J in the game, you have to work around with jboss-deployment-structure.xml.