6 Replies Latest reply on Apr 20, 2012 9:18 AM by hd0815

    logback and JBoss 7.1.1.Final

    hd0815

      Hi,

       

      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:

       

      {code:xml}<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>{code}

       

      The structure of my project is as follows:

       

      {noformat}ear.ear

      |

      |--- lib

      .     |

      .     |--- slf4j-api.jar

      .     |--- logback-classic.jar

      .     |--- logback-core.jar

      |--- ejb.jar

      .     |--- logback.xml

      |--- META-INF

      .     |--- jboss-deployment-structure.xml

      |--- web.war{noformat}

       

      In logback.xml a different log folder is defined. Nothing is logged to this folder.

        • 1. Re: logback and JBoss 7.1.1.Final
          beve

          Hi,

           

          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.

           

          Regards,

           

          /Daniel

          • 2. Re: logback and JBoss 7.1.1.Final
            hd0815

            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.

            • 3. Re: logback and JBoss 7.1.1.Final
              dmlloyd

              hd0815 wrote:

               

              Hi,

               

              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.

              • 4. Re: logback and JBoss 7.1.1.Final
                sfcoy

                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:

                1. Specify -Dlogback.configurationFile=/path/to/config.xml on the command line
                2. Explicitly configure logback from a servlet context listener
                • 5. Re: logback and JBoss 7.1.1.Final
                  hd0815

                  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.

                  • 6. Re: logback and JBoss 7.1.1.Final
                    hd0815

                    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.