2 Replies Latest reply on Jan 7, 2011 10:49 AM by stephane_

    JBoss AS6 logging , how to configure XMLLayout

    stephane_ Newbie



      Migrating from 5.1 to 6.

      I am trying to figure out how to configure a log4j appender with XMLLayout with the new logging format


      Any pointer or doc would be greatly appreciated .





        • 1. Re: JBoss AS6 logging , how to configure XMLLayout
          jaikiran pai Master

          Just a FYI - You don't have to use the jboss-logging.xml file to configure your application's logging. You can always use your own log4j.xml file within your application.

          • 2. JBoss AS6 logging , how to configure XMLLayout
            stephane_ Newbie

            After many trial and error I ended up creating a placeholder appender







                     suffix=".yyyy-MM-dd">  <!-- To roll over at the top of each hour, use ".yyyy-MM-dd-HH" instead -->


            <level name="OFF"/>







                     <!-- To revert back to simple stack traces without JAR versions, change "%E" to "%e" below. -->

                     <!-- Uncomment this to get the class name in the log as well as the category

                     <pattern-formatter pattern="%d %-5p [%c] %C{1} (%t) %s%E%n"/>


                     <!-- Uncomment this to log without the class name in the log -->

                     <pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/>




            and then I set the layout programmatically in a bean


            java.util.logging.Logger logger = java.util.logging.Logger.getLogger("");

                                for (Handler h : logger.getHandlers())




                                          // h.setFormatter(new XMLFormatter())

                                          if (h instanceof PeriodicRotatingFileHandler

                                                              && ((PeriodicRotatingFileHandler) h).getFile().getName().contains(".xml"))



                                                    h.setFormatter(new XMLFormatter());


                                                    logger.info("XML Logger initialized");






            It works if I deploy my bean after the server is started , however it seem that otherwise application (my bean included) are deployed before the app server switches away from the boot logger , so the boot logger get the configuration but not the main logger ...

            Any way to tell JBoss to switch logging before starting applications ?