5 Replies Latest reply on May 30, 2012 12:55 PM by jamezp

    Logging in AS7

    aryan02130

      Could someone provide me info on the logging framework used by AS7. I see that there is a logging.properties file , the logging configurations are also present in standalone.xml/domain.xml file. Does JBoss AS7 use its own logging framework or does it leverage from java.util.logging or log4j?

        • 1. Re: Logging in AS7
          dmlloyd

          JBoss AS7 uses the JBoss LogManager framework.  This is a java.util.logging implementation, which also provides log4j, jboss-logging, and slf4j API implementations (and thus a commons-logging implementation as well).

          1 of 1 people found this helpful
          • 2. Re: Logging in AS7
            aryan02130

            Thank you for the reply. I still have few questions before I understand the logging mechanism used in AS7

             

            1.) When you say JBoss uses JBoss LogManager framework which is a java.util.logging implementation and it also provides log4j, jboss-logging etc, can I configure the framework  to use one of the above implementations for AS7 logging? How is this done ? ( From AS7 perspective) . Or is it that JBoss AS7 always uses LogManager framework with j.u.l ?

             

            2.) Jboss Log Manager framework - can this be used as a standalone jar as well ? (like bundling it into my application)

             

            3.) I have not been able to figure out the difference between JBoss LogManager and jboss-logging. Could you throw some light on this as well please.

             

            I could not find any documentation, hence these questions. Let me know if there exists any documentation on these.

            • 3. Re: Logging in AS7
              jamezp

              1.) When you say JBoss uses JBoss LogManager framework which is a java.util.logging implementation and it also provides log4j, jboss-logging etc, can I configure the framework  to use one of the above implementations for AS7 logging? How is this done ? ( From AS7 perspective) . Or is it that JBoss AS7 always uses LogManager framework with j.u.l ?

              I'm a bit confused on the first part of this question. Do you mean you want to use log4j or another logging facade? For the last part, yes JBoss AS7 will always use JBoss Log Manger for the log manager part. You can use any logging facade, jboss-logging, slf4j, log4j, etc, with JBoss Log Manager.

               

               

              2.) Jboss Log Manager framework - can this be used as a standalone jar as well ? (like bundling it into my application)

              Yes it can be used in a standalone app as a replacement for java.util.logging.LogManager. It's configuration is a lot more sane than J.U.L's log manager too. I would encourge you to use it with jboss-logging for the facade though.

               

               

              3.) I have not been able to figure out the difference between JBoss LogManager and jboss-logging. Could you throw some light on this as well please.

              JBoss Log Manager is a full replacement for java.util.logging.LogManager. This is how handlers and loggers are configured.

               

              JBoss Logging is a logging facade that doesn't care about the log manager being used. This is more like slf4j if I had to make a comparison. This is generally what you would use in your application for logging, e.g. org.jboss.logging.Logger.getLogger(). This is what is used in JBoss AS 7 when an event needs to be logged.

               

               

              Here is a brief explanation of how it works in JBoss AS 7. The logging subsystem configuration is read and configured via the JBoss Log Manager. When an event needs to be logged, then JBoss Logging is used to log the event.

               

              You can get a little more information from the documentation on logging in AS 7.

               

              --

              James R. Perkins

              1 of 1 people found this helpful
              • 4. Re: Logging in AS7
                aryan02130

                Ok, I guess I am still missing something here...You mentioned that jboss-logging is just a logging facade and AS7 used jboss-logmanager (Which is a replacement of j.u.l.)

                 

                1.) what is the default logger/handler implementations used by AS7 (like is it log4j, j.u.l or something else). (also if I need to change this, is custom-handler tag in standalone.xml/domain.xml meant for doing this ?)

                 

                2.) Also, in jboss-logging project I can see JDKLoggers, Log4jLogger, JBossLogManagerLogger classes present. If I use it as an independent library in my project, how does org.jboss.logging.Logger.getLogger() know which implementation to pick from. Where is this configured?

                 

                 

                Update On Point 1 :I was going through the JBoss AS7 code, I guess the partial answer to Point (1) is that AS7 code directly calls the handlers defined in jboss-logmanager. So if I wish to extend this (or use log4j), I hope this is done through custom-handler.

                • 5. Re: Logging in AS7
                  jamezp

                  1.) what is the default logger/handler implementations used by AS7 (like is it log4j, j.u.l or something else). (also if I need to change this, is custom-handler tag in standalone.xml/domain.xml meant for doing this ?)

                  For configuring loggers and handlers, JBoss Log Manager is used. You can add a custom handler, but the implementation won't change. Currently a custom handler would have to extend java.util.logging.Handler, but it seems that log4j appenders are also supposed to be allowed https://issues.jboss.org/browse/AS7-4925. I'm not too sure how or when that's going to be implemented yet though.

                   

                   

                  2.) Also, in jboss-logging project I can see JDKLoggers, Log4jLogger, JBossLogManagerLogger classes present. If I use it as an independent library in my project, how does org.jboss.logging.Logger.getLogger() know which implementation to pick from. Where is this configured?

                  It all depends on the log manager you're using. It searches for this in the following order; JBoss Log Manager, log4j, slf4j with logback and finally falls back to java.util.logging.LogManager if the others are not found. There is also a system property org.jboss.logging.provider to specify the log manger you'd like to use. The allowed values are; jboss, log4j, slf4j and jdk. Note that if you speficy slf4j in the system property it's not required to use logback with it.

                   

                  --

                  James R. Perkins