3 Replies Latest reply on Apr 18, 2013 4:00 PM by jamezp

    Logging - log4j AND slf4j

    johnson_shawn

      I am using JBoss 7.1.x, and have configured my logging in the standalone.xml.  Recently added a 3rd party library using slf4j.  Our app uses log4j.  I have the following in my jboss-deployment-structure.xml (WAR file deployment):

       

       

        <dependencies>
        <module name="org.apache.log4j" />
        <module name="org.jboss.resteasy.resteasy-jettison-provider" />
        <module name="org.infinispan"/>
        <module name="org.hornetq"/>
        <module name="org.jboss.remoting3.remoting-jmx" services="import"/>
        <module name="org.slf4j" />
        </dependencies>
      

       

      With the org.slf4j most recently added.  Now the FILE handler that I defined for my application loggers isn't receiving logs anymore.

       

      What SHOULD my configuration be?

        • 1. Re: Logging - log4j AND slf4j
          jamezp

          One note as of 7.1.1.Final you don't need to add org.apache.log4j or org.slfj as dependencies. They are both added to each deployment by default.

           

          The only thing I can think of is that maybe you have a slf4j implementation, like maybe an slf4j-log4j12, being bundled with your deployment.

           

          --

          James R. Perkins

          • 2. Re: Logging - log4j AND slf4j
            johnson_shawn

            Thanks James, we did end up removing the log4j module from our dependency file.  We didn't have any slf4j libs in our deployment - we were thinking the same thing.

             

            We also ended upgrading to jboss-as-713.

             

            We explicitly defined each package/class that we wanted to log in the standalone.xml logging subsection.  Also we explicitly added stdout and stderr definitions.  Lastly we defined a log4j.xml to turn off some double-logging we were getting.  This seems to do the trick for us now.  We also updated our code to use sfl4j, then let JBoss logging handle everything.

             

            Hope this helps someone else.

             

            The only thing that seemed odd is how we only get logging if we explicitly define a logger for the package/class.

            • 3. Re: Logging - log4j AND slf4j
              jamezp

              Yeah you shouldn't have to define loggers for each package/class. The root-logger should handle that.

               

              --

              James R. Perkins