4 Replies Latest reply on Apr 5, 2010 10:57 AM by Peter Johnson

    logging config for container managed logging

    R Carr Newbie

      I'm using jboss 4.3 and I'm trying to setup container managed logging.  In my web application I've removed any logging libraries from WEB-INF/lib and any logging configuration from WEB-INF/classes.  Currently, my code is compiled against log4j, but eventually I'd like to switch to commons logging.

       

      My jboss lib folder contains both the commons-logging jar and the log4j jar.  My first thought was to put my logging configuration (log4j.properties) into the deploy folder, but that didn't work.  Then I tried putting it in the lib folder (which is how the tomcat docs describe how to do this), but that didn't work either.

       

      Then I looked in the conf folder and saw the file jboss-log4j.xml.  I added a new appender (with a debug priority) and a new category (named the base of my package structure) and restarted jboss.  The file I specified in the appender was created, however, nothing was ever logged to it (and there should have been).

       

      Before, when I had the log4j jar in my WEB-INF/lib folder and my logging config in WEB-INF/classes, everything worked fine.  However, I'd like the logging to be controlled outside of my application, so I've been experimenting.

       

      So, I have two questions:

       

      1) How do I configure logging for my application, but outside of my application?  As I've described, nothing seems to work.

       

      2) Eventually, I'd like to change my code to use commons logging, and also configure the logging outside of the application.  Since log4j is the default of commons logging, if I solve (1) I would expect it to "just work", but how would I explicitly specify log4j (or, say, I wanted to use jdk logging)?

       

      Thanks!

        • 2. Re: logging config for container managed logging
          R Carr Newbie

          Hi Peter-

           

          Thanks for the link, but if I'm reading it right, no ... it doesn't seem to answer my question.

           

          It talks about putting log4j config files within your application, but I'm strictly trying to avoid that.

           

          I want the container (jboss) to have complete control over the logging of my application.  Right now I'm just talking about controlling the loggers and appenders in log4j, but as I said, I eventually want it to also control the log library that is used (when I switch to commons logging).

           

          Is your link saying this isn't possible?  Is there no way to completely control the logging config outside of the app that is doing the logging?

          • 3. Re: logging config for container managed logging
            jaikiran pai Master

            R Carr wrote:

             


             

            I want the container (jboss) to have complete control over the logging of my application.  Right now I'm just talking about controlling the loggers and appenders in log4j, but as I said, I eventually want it to also control the log library that is used (when I switch to commons logging).

             

            Is your link saying this isn't possible?  Is there no way to completely control the logging config outside of the app that is doing the logging?

            If you want to configure the logging from outside your app, then configuring the JBOSS_HOME/server/< servername>/conf/jboss-log4j.xml should work. As for changing the log library, you can definitely use any other logging implementation. It's upto your application to package those jar files in the application and configure logging using some config file (each implementation will have different API to configure it).

            • 4. Re: logging config for container managed logging
              Peter Johnson Master

                   >>Thanks for the link, but if I'm reading it right, no ... it doesn't seem  to answer my question.

              Actually, I was not answering your questions, except in perhaps a round-about way. The link contains a complete set of change to jboss-log4j.xml that enable an app to log to a seperate log file. So the link was really to help with this statement you made:

               

              >>I added a new appender (with a debug priority) and a new category (named  the base of my package structure) and restarted jboss.  The file I  specified in the appender was created, however, nothing was ever logged  to it (and there should have been).