4 Replies Latest reply on Apr 15, 2011 3:50 AM by jaikiran pai

    jboss 6 boot logging handler removal

    Jeff Greif Newbie

      I just reworked the logging in my application to use java.util.logging instead of log4j, the better to integrate with JBoss 6.

       

      During deployment of my application (EAR), some additional java.util.logging.FileHandlers are created and attached to the root logger.

       

      But then, apparently at the end of the startup process, when the boot logging is replaced by the configuration in jboss-logging.xml, my application's handlers are removed and closed.  The last message logged is usually "Removing bootstrap log handlers."

       

      Why are my application's log handlers considered to be part of the set of bootstrap log handlers?

       

      Is there some way to avoid this problem?

       

      Shouldn't only the handlers set up in boot-logging.properties be removed?

       

      Note:  The version of JBoss 6 I am running includes the patches for JBAS-8791-1.

        • 1. Re: jboss 6 boot logging handler removal
          Elias Ross Master

          The short term fix likely is to add your appender/log handler into jboss-logging.xml ... duplicate configuration, I know.

           

          I would think the default expectation of a user is the jboss-logging.xml at start/restart basically would remove all appenders.

           

          That being said, you can explore patching this issue on your own. It's unlikely it will be fixed without a user provided patch.

          • 2. jboss 6 boot logging handler removal
            jaikiran pai Master

            Jeff Greif wrote:

             

            I just reworked the logging in my application to use java.util.logging instead of log4j, the better to integrate with JBoss 6.

             

            During deployment of my application (EAR), some additional java.util.logging.FileHandlers are created and attached to the root logger.

             

            But then, apparently at the end of the startup process, when the boot logging is replaced by the configuration in jboss-logging.xml, my application's handlers are removed and closed.

            Since you are attaching it to the root logger which are part of the bootstrap process, I guess it's no surprise that they are wiped off when the logging is switched to jboss-logging.xml. I think, if you somehow manage to "wait" till the switching has been done and then attach your appenders, that should get you past this.

             

            How are you attaching the appenders from your application? What kind of code is is? ServletContextListener?

            • 3. Re: jboss 6 boot logging handler removal
              Jeff Greif Newbie

              1.  The app-specific logger initialization is done in code called from the init() method of a load-on-startup servlet.  The handlers are attached using java.util.logging.Logger.getLogger("").addHandler(handler);  This code is utility code that is also used for setting up logging for java programs not running in the AS.

               

              2.  When the logging switches to jboss-logging.xml, the handlers specified in the boot-logging.properties, and only those handlers, should be removed from the root logger.  If the root logger is also nuked, any other handlers attached to the root should be attached to the new root logger.  Otherwise any logging configuration done during deployment will be lost. 

               

              3.  Following some recommendations you made in posts several weeks ago, I added a jboss-logging.xml file to my EAR's META-INF directory, that creates a (throwaway) log handler that will produce little output and attaches it to a non-root-category logger.  This seems to disturb the bootstrap log handlers removal process in such a way the handlers which were erroneously being closed before the config file was added, are now left open and working. Note that those handlers that were formerly erroneously closed are still being set up the same way as they were (not in the app-specific jboss-logging.xml).

               

              4.  So putting something into an app-speciific jboss-logging.xml seems to be a workaround.  Is there an explanation for this behavior?

              • 4. Re: jboss 6 boot logging handler removal
                jaikiran pai Master

                Jeff Greif wrote:

                 

                 

                 

                2.  When the logging switches to jboss-logging.xml, the handlers specified in the boot-logging.properties, and only those handlers, should be removed from the root logger.  If the root logger is also nuked, any other handlers attached to the root should be attached to the new root logger.  Otherwise any logging configuration done during deployment will be lost. 

                The root cause of all these problems is that the boot logging in AS6 stays too late during the server startup process. The boot logging keeps being used even when the deployments are being deployed which effectively means that any changes that you do to the loggers from the application, will be wiped off when the boot logging is switced to jboss-logging.xml. Ideally, the boot logging should switch to jboss-logging.xml before applications start being deployed. But this is a known issue https://issues.jboss.org/browse/JBAS-7681.

                 

                As a workaround, try creating a deploy.last folder within JBOSS_HOME/server/<servername>/deploy folder and place your .ear within that deploy.last folder. That way, the bootstrap to jboss-logging.xml switch should happen before your application is deployed and the load-on-startup servlet called. See if that helps.