8 Replies Latest reply on Nov 22, 2012 5:10 AM by teg79

    Unable to exclude JBoss 7 logging modules

    teg79

      Hi guys,

      I'm porting a EAR application to JBoss 7, in our requirements we have to use the Logback DB Appender, our customer has developed tools to read that DB logs and we must support this logging system.

       

      In this forum we found some documentation about jboss-depoyment-structure.xml, but after many modifications we are still unable to exclude the JBoss logging system for our application.

       

      Here the jboss-deployment-structure.xml:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <jboss-deployment-structure>

          <deployment>

              <exclusions>

                  <module name="org.slf4j" />

                  <module name="org.slf4j.impl" />

                  <module name="ch.qos.logback" />

                  <module name="org.apache.commons.logging"/>

                  <module name="org.apache.log4j"/>

                  <module name="org.jboss.logging"/>

                  <module name="org.jboss.logging.jul-to-slf4j-stub"/>

                  <module name="org.jboss.logmanager"/>

                  <module name="org.jboss.logmanager.log4j"/>

              </exclusions>

          </deployment>

       

       

          <sub-deployment name="my-ejb.jar">

              <exclusions>

                  <module name="org.slf4j" />

                  <module name="org.slf4j.impl" />

                  <module name="ch.qos.logback" />

                  <module name="org.apache.commons.logging"/>

                  <module name="org.apache.log4j"/>

                  <module name="org.jboss.logging"/>

                  <module name="org.jboss.logging.jul-to-slf4j-stub"/>

                  <module name="org.jboss.logmanager"/>

                  <module name="org.jboss.logmanager.log4j"/>

              </exclusions>

          </sub-deployment>

       

       

          <sub-deployment name="my-web-2.0.0-SNAPSHOT.war">

              <exclusions>

                  <module name="org.slf4j" />

                  <module name="org.slf4j.impl" />

                  <module name="ch.qos.logback" />

                  <module name="org.apache.commons.logging"/>

                  <module name="org.apache.log4j"/>

                  <module name="org.jboss.logging"/>

                  <module name="org.jboss.logging.jul-to-slf4j-stub"/>

                  <module name="org.jboss.logmanager"/>

                  <module name="org.jboss.logmanager.log4j"/>

              </exclusions>

          </sub-deployment>

       

       

          <sub-deployment name="another-web-1.0.0-SNAPSHOT.war">

              <exclusions>

                  <module name="org.slf4j" />

                  <module name="org.slf4j.impl" />

                  <module name="ch.qos.logback" />

                  <module name="org.apache.commons.logging"/>

                  <module name="org.apache.log4j"/>

                  <module name="org.jboss.logging"/>

                  <module name="org.jboss.logging.jul-to-slf4j-stub"/>

                  <module name="org.jboss.logmanager"/>

                  <module name="org.jboss.logmanager.log4j"/>

              </exclusions>

          </sub-deployment>

      </jboss-deployment-structure>

       

      We put also a similar file (without sub-deployments) in each application module in META-INF for the ejb-jar and in WEB-INF for the 2 web apps.

       

      The result is always the same, JBoss still use its internal logging.

       

       

       

      Thanks in advance for the help

      Francesco

        • 1. Re: Unable to exclude JBoss 7 logging modules
          rhanus

          I wouldn't exclude logging modules in jboss-depoyment-structure.xml

          I would log in source files as usually using jboss/log4j logging facility and would use custom logger (custom-handler) defined in standalone.xml in subsystem logging

          see $JBOSS_HOME/docs/schema/jboss-as-logging_1_1.xsd for more details

          1 of 1 people found this helpful
          • 2. Re: Unable to exclude JBoss 7 logging modules
            teg79

            Thanks for your response Radim,

            do you mean to make logging like this?

             

            myapp -> slf4j-api -> slf4j-over-jboss-logging -> jboss-logging -> (log4j?) -> custom-handler (to be implemented) -> logback db appender

             

            Now our logging is:

             

            myapp -> slf4j-api -> logback

             

            Do you think performance will be the same?

             

             

            In my honest opinion is a bad idea to write additional code and to access the Logback DB appender directly, we will lose the ability to configure it via logback.groovy and we have to reimplement the same code Logback provide to use the appender with slf4j

            • 3. Re: Unable to exclude JBoss 7 logging modules
              rhanus

              ok if you want to reduce internal jboss logging then configure in standalone.xml level of root-logger to WARN or ERROR and your packages to desired level

              if you want to suppress logging at all then comment out handlers in root-logger but you will have no clue what's happen inside server

              • 4. Re: Unable to exclude JBoss 7 logging modules
                teg79

                Sorry Radim,

                my problem isn't the JBoss logging messages, but to log many messages from my application to a DB via Logback in the fastest way.

                 

                I think it is possible to avoid the auto-dependency like jboss logging and to use my internal logging system.

                The documentation says that this is possible, but with the jboss-deployment-structure.xml provided in the first post I cannot get this solution working

                • 5. Re: Unable to exclude JBoss 7 logging modules
                  jamezp

                  What version of JBoss AS? Are you including logback in your deployment? Since you're deployment is an EAR the logback jar should probably be in the EAR/lib directory so it can be shared. Note too that all system logging will still be processed through the logging subsystem. Only log statements through your deployment will be logged via your configuration.

                   

                  --

                  James R. Perkins

                  • 6. Re: Unable to exclude JBoss 7 logging modules
                    teg79

                    I'm using JBoss AS 7.1.1

                    slf4j and logback are in my ear/lib folder and the manifest of every jar has a classpath reference to that jars.

                     

                    I'm interested to log with logback only my internal log messages, for me is fine to use JBoss logging for the application server and external libs log messages.

                     

                    I think the problem is logback, its a native slf4j implementation so to use it you must do it via slf4j api and JBoss forces its internal slf4j api.

                    • 7. Re: Unable to exclude JBoss 7 logging modules
                      jamezp

                      You're telling the server to ignore it's version of the slf4j API by excluding the org.slf4j module. I'm not too sure why this wouldn't be working. Do you see any errors or are things just not being logged? Have you tried adding an additional appender to make sure it's not just an issue with the DB appender?

                       

                      --

                      James R. Perkins

                      • 8. Re: Unable to exclude JBoss 7 logging modules
                        teg79

                        All the application logs are logged only via the JBoss defined appenders, we dont have any error messages in the console so we assume JBoss injected his slf4j implementation in our application.

                        We defined some file and console appenders in logback but they are ignored.

                         

                        Seems that the jboss-deployment-structure.xml file is not enough to exclude JBoss logging modules.

                        BTW, I have a dependency on jboss netty, this can be the problem in your opinion?