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
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.