5 Replies Latest reply on Sep 14, 2012 3:39 PM by ozizka

    per app logging

    herb

      Hi,

       

      I'm looking for solution for my logging problem. My problem is that a per app logging seems not to be possible with AS7 means (see https://issues.jboss.org/browse/AS7-514).

      So, does anybody know a solution or does anybody have an idea how to do it (I'm not afraid of coding)? Any suggestion well be appreciated!!

       

      I like to (or better: I had to) deploy N applications on one AS7 instance. If I use the build in AS7 logging, all the stuff from all the different deployments get to one log file - it will be not fine to read and I cannot (easily) send the application specific parts to the (different) application managers.

       

      I saw some hints to define multiple output files in standalone.xml (e.g. http://community.jboss.org/message/639897#639897) - this works fine for the application specific parts, but I havn't found a solution how to put e.g. the hibernate logging messages to the correct (=to the coresponding application log file) log file? - Any suggestions??

       

      I also found some info how to do this in AS4/AS5 (log4j.jar in WEB-INF/lib and changing the classloader behaviour in jboss-web.xml), but this seems not to work in AS7?

       

      All suggestions are welcome! - Thanks!

        • 1. Re: per app logging
          kavandesai

          Hi herb,

           

          If you have spring based application than the following logging configuration should generate application specific log in JBOSS AS 7.1.0 Beta without any changes in standalone.xml

           

          # For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!

          # For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.

          log4j.rootLogger=INFO, logfile

           

          #log4j.appender.stdout=org.apache.log4j.ConsoleAppender

          #log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

          #log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n

           

          #log4j.appender.stdout=org.apache.log4j.ConsoleAppender

          #log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

          #log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n

           

           

          log4j.appender.logfile=org.apache.log4j.RollingFileAppender

          log4j.appender.logfile.File=${jboss.server.log.dir}/applicationname.log

          log4j.appender.logfile.MaxFileSize=512KB

          # Keep three backup files.

          log4j.appender.logfile.MaxBackupIndex=3

          # Pattern to output: date priority [category] - message

          log4j.appender.logfile.layout=org.apache.log4j.PatternLayout

          log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n

           

          log4j.logger.org.springframework.samples.petclinic.aspects=DEBUG

          log4j.appender.logfile.Threshold=INFO

           

          log4j.logger.org.hibernate.SQL=INFO,logfile

          log4j.additivity.org.hibernate.SQL=false

           

          log4j.logger.org.hibernate.type=logfile

           

          I have placed log4.properties inside /WEB-INF/classes, log4j and commons-logging inside /WEB-INF/lib.

           

          It worked for me.

          • 2. Re: per app logging
            jamezp

            Currently there is no real way to do application specific logging, though we are working on it. There has been some work done on it, but it needs to be merged with some other logging work before it can be pushed upstream.

            • 3. Re: per app logging
              herb

              Thank you for answering!

               

              @Kavan:

               

              It works for me for all classes and lib which are in WEB-INF/classes and WEB-INF/lib but not e.g. for jars which are in modules (e.g. hibernate, beanutils, ...). The loglines for these jars aren't put to the app specific logfile.

               

              Is this stuff working in your environment?

               

              Do you really use AS7? Or are you using AS6/5/4? (because there is "$JBOSS_HOME/server/default" in your sample, which doesn't exist in AS7).

               

              Thanks,

               

              herb

              • 4. Re: per app logging
                kavandesai

                Yes I am using JBOSS AS 7.1.0 Beta. 

                "because there is "$JBOSS_HOME/server/default" in your sample, which doesn't exist in AS7"

                the above line is commented .  Besically I was using 'petclinic' open source spring application.

                 

                "It works for me for all classes and lib which are in WEB-INF/classes and WEB-INF/lib but not e.g. for jars which are in modules (e.g. hibernate, beanutils, ...). The loglines for these jars aren't put to the app specific logfile"

                I can see hibernate statement as well in the same log file I have checked it by keep "show_hibernate_query" to true.

                • 5. Re: per app logging
                  ozizka