2 Replies Latest reply on Mar 22, 2013 2:27 PM by James Perkins

    Logging into multiple files dinamically with JBoss7

    João Rebelo Newbie



        I'm analizing the migration of my applications from JBoss 5 to JBoss 7, but having a problem on Logging infrastructure.


        My applications, process's multiple services in the same environments.

        For each service I dinamically create a new logger file (not configured, but programatically) and use it (code below).


        But using the current Jboss7 configuration with a periodic-rotating-file-handler on my standalone file and org.jboss.logmanager.handlers.FileHandler at logging.properties file I no longer have direct access to RootLogger Appenders.

         I've inspected the RootLogger object returned and (it seems for me that) it's using a LoggerNode instead witch inside has the configured file appender. I've tried to look a API to reach the LoggerNode and haven't found it.


        Does anyone knows a way to replicate this log file dinamism at JBoss 7, or maybe some other logging configuration that would allow this functionalities?



        Follows code for JBoss 5.


                      //Get Root Logger and its File Appender

                      Logger mainLogger = Logger.getRootLogger();

                      Appender appender = mainLogger.getAppender("FILE");


                      //Create New Appender for new Log file

                      if (fileAppender instanceof DailyRollingFileAppender)


                          DailyRollingFileAppender newrfa = new DailyRollingFileAppender(fileAppender.getLayout(),

                                                                                         filePath + logName + ".log",

                                                                                         ((DailyRollingFileAppender) fileAppender).getDatePattern());

                          newFileAppender = newrfa;



                      //Copy configuration from Root Loger












                          // Inherit the remaining of the appenders defined in

                          // root, if any

                          Enumeration<?> apps = mainLogger.getAllAppenders();

                          if (apps != null)


                              while (apps.hasMoreElements())


                                  Appender a = (Appender) apps.nextElement();

                                  if (!a.getName().equalsIgnoreCase("FILE"))


                                      // skip file, already have our own





        • 1. Re: Logging into multiple files dinamically with JBoss7
          João Rebelo Newbie

          Some update on this issue.


          We've tried with JBoss EAP 6.1.0.Alpha, since it's using logging 1.2 and per-deployment logging.

          In this environment and setting log4j.properties in each ear we've made this code to work.


          Although this would solve it has the big inconvenience of having to put the log4j properties file in each ear. Considering the solution uses 20+ ears this is a configuration pain if someday we'll have to change the log4j configuration.


          So, the question remains, is there a way to access the appenders/LoggerNode on jboss logging, or using per-deployment logging to only configure the log4j on a module?



          • 2. Re: Logging into multiple files dinamically with JBoss7
            James Perkins Master

            If you're using JBoss EAP 6.1.0.Alpha there is a concept of logging profiles. This sounds like what you might want here. Each profile is it's own logging configuration and allows for runtime changes which the per-deployment logging does not handle.



            James R. Perkins