3 Replies Latest reply on Sep 6, 2011 6:04 AM by javapenguin

    Problems with JBoss 6 logging

    robinsri

      Hi,

       

      The logging in JBoss 6 has really changed. There are some good features in it but, unfortunately, the changes don't mix well with my application's logging. In fact the app's special trace logging now fails miserably.

       

      What is perhaps special about the app is that it uses an associated console which gives users the ability to turn off and on tracing on various subsystems as well as the ability to control the location of the log file. No changes to the XML config are needed. It does this by fetching log4j loggers, creating new appenders as needed and using the addAppender/removeAppender as well as seting levels to control the tracing and, when tracing is enabled, send error logging to the the regular error log file and duplicate it in a trace log file. When tracing is off then errors only go to the error log and the trace log is left alone. Users can also use API calls to the app to control the loging themselves if they don't want to use the console.

       

      I see two problems with the new JBoss 6 logging:

       

      1) The loggers appear to be adapters of the BridgeLogger class rather than real log4j Logger object and don't appear to implement all the features of log4j (e.g., addAppender)

       

      2) Initialization of the loggers is done during the time that the boot logging is in affect. That means that even if (1) was fixed, any changes made programmatically are made to the wrong logging configuration. That would be the case if tracing was enabled and JBoss was restarted and the code tried to initialize for tracing.

       

      Other than putting a copy of the log4j.jar in my EAR and changing the classloaders to load it rather than the JBoss instance is there anyway to get back the old log4j logging? Help!

       

      Thanks!

      Rick 

        • 1. Problems with JBoss 6 logging
          jaikiran

          You don't really have to use jboss-logging. Instead, you can use log4j directly (like you say by packaging your log4j.jar and the log4j.xml in your app), if you really are relying on log4j.

          • 2. Problems with JBoss 6 logging
            genman

            Still...I've run into issues with the BridgeLogger class and I think jboss-logging *could* do a better job emulating Log4j a bit better.

             

            Mostly it would require you to adapt your Appender to java.util.logging.Handler instance, and deal with the calls to Logger.getAppender, addAppender, etc. Probably the former's been done before since both APIs are popular.

            • 3. Re: Problems with JBoss 6 logging
              javapenguin

              Is there anyway I can setup jboss 6 to use log4j insead of packaging it in my ear?