11 Replies Latest reply on Feb 28, 2011 7:20 AM by Norsay Norsay

    Application specific jboss-logging.xml

    Norsay Norsay Newbie

      Hi

       

      We are currently migrating our applications to JBoss AS 6 where I'm facing some logging related problems.

       

      1. I'm unable to find any useful documentation for jboss-logging.xml... Any hints where I can find such a documentation? Without documentation our operation center will refuse to operate an JBoss app server, I think... And I'm also unable to summarize the most important steps for our operation guys.

       

      2. My goal is to have an external logging configuration per application, because they may differ (for example the log level) between our plattforms. So I'm trying to setup an application specific logging (which should be possible with 6.0 M2 and later).  I tried to define an application specific logging context (I guess it has to be defined in META-INF/jboss-logging.xml) and to refer that context from my external log config file. However I had no chance to setup such a szenario without documentation. Any ideas, hints, example configuration to solve the problem would be very appreciated!

       

      BTW: If I don't find a solution, that will be the end of JBoss in our company :-(

       

      Cherrs

       

      norsay

        • 1. Application specific jboss-logging.xml
          jaikiran pai Master

          I've seen many users asking for this now. But before I go digging into the details, do you really want to configure logging through jboss-logging.xml or are you OK with setting it up with your application specific log4j.xml (if you are using Log4j)?

          • 2. Application specific jboss-logging.xml
            Norsay Norsay Newbie

            There are several threads about that topic, you are absolutly right However I didn't find a useable answer for me...

             

            Well, there is no absolut "must" for me to use jboss-logging.xml. If there is an other way to define an application specific logging (and as such seperate the logs into different files and log level into different files), that would also be acceptable for me or better the guys who have to operate JBoss...

            • 3. Application specific jboss-logging.xml
              jaikiran pai Master

              Norsay Norsay wrote:

               

              If there is an other way to define an application specific logging (and as such seperate the logs into different files and log level into different files), that would also be acceptable for me or better the guys who have to operate JBoss...

              Assuming that your application is using log4j for logging, it is possible to package a log4j.xml in each of your applications and the configuration in the log4j.xml can then direct the logs to separate log files (one each for each application). Furthermore, you can control the log levels of each application, separately in each of those files. However, the only "disadvantage" of this approach is that you can't change the logging levels or any other logging configurations of these applications, dynamically without redeploying the entire application - but that's the same even if when you package the jboss-logging.xml within each of the applications.

               

              For an example on how to configure application specific log4j files, take a look at this thread http://community.jboss.org/message/198690#198690 (that was meant for JBoss AS 4.2.x, but I believe should be applicable even for AS6).

               

              If you have more questions, feel free to ask.

              • 4. Re: Application specific jboss-logging.xml
                Norsay Norsay Newbie

                Thanks for your answer! Correct me if I'm wrong, but it looks like the log4j.xml must be packed into the EAR file. As a consequence I have to repack the EAR (and change the log4j.xml) for each environment which should have different logging behavior... Ok, if there is no other way, this could be a fall back scenario. However my goal is to have a EAR independant configuration (in other words, the EAR artifact must not contain any environment specific informations). Dynamic logging configuration changes are not in the scope...

                 

                Just to bring some more light into the dark, the concret deployment scenario looks like this:

                - We use Maven to build a release and as a result we have a EAR artifact.

                - The EAR will be deployed to different systems/environment (let's call them integration, test and production)

                - The logging configuration must be defined per system (because we like to see debug information only on integration system - in production environment we would like to log only warnings and errors) - so we like to have an external configuration for the logging per environment (without having to repack the EAR of course)

                • 5. Application specific jboss-logging.xml
                  jaikiran pai Master

                  Norsay Norsay wrote:

                   

                  Thanks for your answer! Correct me if I'm wrong, but it looks like the log4j.xml must be packed into the EAR file.

                  That's correct, it'll have to go in each .ear file.

                   

                   

                  Norsay Norsay wrote:

                   

                  Just to bring some more light into the dark, the concret deployment scenario looks like this:

                  - We use Maven to build a release and as a result we have a EAR artifact.

                  - The EAR will be deployed to different systems/environment (let's call them integration, test and production)

                  - The logging configuration must be defined per system (because we like to see debug information only on integration system - in production environment we would like to log only warnings and errors) - so we like to have an external configuration for the logging per environment (without having to repack the EAR of course)

                  Right, that's the "disadvantage" I was talking about. I understand that using the server profile level jboss-logging.xml to control the logging is convenient and helps get past these issues. So yeah, let me see if I can put together something during this weekend.

                  • 6. Re: Application specific jboss-logging.xml
                    Norsay Norsay Newbie

                    Ok, great Looking forward reading from you

                    • 7. Re: Application specific jboss-logging.xml
                      Norsay Norsay Newbie

                      Are there any news about this logging issue? I should have a solution till end of this week...

                      • 8. Application specific jboss-logging.xml
                        jaikiran pai Master

                        I did try this partially on a weekend and found that there's a bug in there http://community.jboss.org/message/588710#588710. I could find a workaround too, but couldn't yet spend more time in getting it completely working.

                        • 9. Re: Application specific jboss-logging.xml
                          Norsay Norsay Newbie

                          No problem. Any hints or workaround for this problem are still very welcome

                          • 10. Application specific jboss-logging.xml
                            Noa Drach Novice

                            another approach will be to implement a repository selector.

                             

                            this is described in section 10.3.8 here - http://docs.jboss.org/process-guide/en/html/logging.html

                             

                            and also here - http://community.jboss.org/wiki/Log4jRepositorySelector

                             

                            this is what i did in my app - the benefit of this approach is that you don't package the log4j.jar in the app and you are telling it from where to take the configurations file - so changing the configuration won't imply a redeploy of your app

                             

                            the only thing you need to watch when using the repository selector is that you need to do the initialization in all the relevant class loaders.

                             

                            i did a base class for EJBs that has a post construct method to init the log.

                            • 11. Re: Application specific jboss-logging.xml
                              Norsay Norsay Newbie

                              Great hint, thanks a lot! Guess I have to look at this solution a bit closer