6 Replies Latest reply on Oct 28, 2010 1:50 PM by Krashan Brahmanjara

    SLF4J vs. Commons Logging

    Juergen Zimmermann Master
      Hibernate was migrating to SLF4J, and JBossAS is (still?) using Commons Logging. I'm wondering if there are any plans also to migrate to SLF4J?
        • 1. Re: SLF4J vs. Commons Logging
          David Lloyd Master

          Juergen.Zimmermann wrote:

           

          Hibernate was migrating to SLF4J, and JBossAS is (still?) using Commons Logging. I'm wondering if there are any plans also to migrate to SLF4J?

           

          JBossAS does not "use" Commons Logging per se; it is supported but is not the basis of logging.  As of JBossAS 5, applications may choose to use slf4j, log4j, commons-logging, JBoss-logging, or java.util.logging, or any framework which logs to or via any of these, and all log messages will go to the same log.

          • 2. Re: SLF4J vs. Commons Logging
            Kevin Pauli Newbie

            So how does one configure JBoss AS 5.1.0.GA to use slf4j?

             

            I also posted this question in a response here:  https://community.jboss.org/message/206059#206059

            • 3. Re: SLF4J vs. Commons Logging
              David Lloyd Master

              One doesn't, generally.  SLF4J is not a logging backend or service, it's an API.  Applications using slf4j should "work" when run inside of JBossAS in that their logged messages will appear in the log at the expected levels.  The real question would be "how does one configure JBoss AS 5.1.0 to use LogBack?".  The answer to that is, one doesn't; log4j is the only supported logging backend in all AS 5.x releases.

               

              In your other thread you mention using a logback log viewer.  Have you considered setting up a log format which is equivalent to whatever the format LogBack is using?

              • 4. Re: SLF4J vs. Commons Logging
                Steve Dodge Newbie

                Let me know if this is accurate.  In Jboss 5.x, I have a war file  using slfj4.   All I need to do is deploy that app with the slf4j jar  files included in its WEB-INF/lib?    Jboss will take over and route the  logging through the Log4j backed?  Or, will I need to take percation not to include logging libraries such as slf4j?  Also, do I need to make sure I  don't include my own version of Log4j.jar as that will collide with the  one packaged with Jboss correct?

                 

                On Jboss 4.2.x we have to take these precautions.

                 

                Thanks

                -steve

                • 5. Re: SLF4J vs. Commons Logging
                  David Lloyd Master

                  You should only include your own log4j.jar and slf4j*.jar if you are opting to not use the JBossAS logging mechanism.  If you want to use the main server log, do not include any logging JARs as all of the major APIs are provided by the AS.

                  • 6. Re: SLF4J vs. Commons Logging
                    Krashan Brahmanjara Newbie

                    It seems to me that on  JBoss AS 5.1 it doesn't work correctly. I got ear application with ehcache jars in APP-inf/lib subdirectory .

                    Ehcache uses sl4j and I can't configure and enable this logging with jboss-log4j.properties file.

                    What should I do? I don't want to copy these jar's to  server lib or common directory.