I'm not sure about this but could you try adding the 'org.apache.log4j' module to the list of excluded modules. I believe that it this module is added implicitily and might be an issue.
I added org.apache.log4j to the excluded modules in deployment tag and every sub-deployment tag, but that didn't fix the problem. No log file is added to my user defined log directory. Everything is logged into server.log.
I'm facing problems in getting my enterprise application read the logback.xml and configure my logger.
I read several discussions about this issue already, but nothing seems to work for me. For some reasons I need to use logback and cannot switch to a different logging framework.
I tried to exclude org.slf4j in my deployment and all sub-deployments in jboss-deployment-structure.xml, but this had no effect. Everything is still logged to server.log and only to server.log.
Here is my jboss-deployment-structure.xml from the ear-File:
<jboss-deployment-structure> <deployment> <exclusions> <module name="org.sl4j" /> <module name="org.slf4j.impl" /> </exclusions> </deployment> <sub-deployment name="ejb.jar"> <exclusions> <module name="org.sl4j" /> <module name="org.slf4j.impl" /> </exclusions> </sub-deployment> <sub-deployment name="web.war"> <exclusions> <module name="org.sl4j" /> <module name="org.slf4j.impl" /> </exclusions> </sub-deployment> </jboss-deployment-structure>
The structure of my project is as follows:
ear.ear | |--- lib . | . |--- slf4j-api.jar . |--- logback-classic.jar . |--- logback-core.jar |--- ejb.jar . |--- logback.xml |--- META-INF . |--- jboss-deployment-structure.xml |--- web.war
In logback.xml a different log folder is defined. Nothing is logged to this folder.
I think the problem is that you spelled "slf4j" wrong in your exclusions.
This does not work for exactly the same reasons that affect log4j.
As the logback jars are in the EAR/lib directory, they cannot "see" the logback.xml file in the ejb.jar as it's in a different classloader.
Your choices are to:
- Specify -Dlogback.configurationFile=/path/to/config.xml on the command line
- Explicitly configure logback from a servlet context listener
Thanks, I didn't realize that. It seems that I now get the correct logging API but in fact it still isn't realizing the logback.xml. This may be because of the Problem metioned by Stephen Coy. I'm on that already.
Well, after I fixed my typo in jboss-deployment-structure.xml it didn't work. But I found out that this file wasn't deployed by my JBoss Tools Eclipse plugin. After I copied the file to ear.ear/META-INF in the deployment folder the application was able to find and read logback.xml located at ear.ear/ejb.jar. I have to add that I have a fully exploded deployment. This means even ejb.jar and web.war are exploded archives like JBoss Toold does. I haven't tested if the logback config file can be read when it's archived.