4 Replies Latest reply on Apr 10, 2002 1:09 PM by tewk

    Log4j problem.

    fstarsinic

      Log4J is Great. JBoss is Great.
      They work great together except when....

      i want to use Log4j in my Message-Driven Bean.

      since Log4j is an MBean in JBoss, my calls to log4j within my MDB do not find Log4j.

      So my only options that i see are
      Don't use log4j
      comment out the mbean in jboss.conf for log4j
      and inlcude it in my classpath before starting
      jboss.

      is there another solution?

      thanks,

      frank

        • 1. Re: Log4j problem.
          jimboj

          Hi Frank,

          We have used log4j in our beans and web classes. We extend the category class to provide our own. This causes class cast exception when redeploying due to JBoss's use of log4j. To get around these issues we ended up putting the extended category in a jar on the classpath (lib/ext) so that it was not redeployed each time, thus no class cast.

          Also, and more specific to your question is you can add a line into the jboss.conf file for the log4j service to direct it to another config file. We have





          to use the log4j-config.xml file as the log config file instead of the log4j.properties used by JBoss. This means that it picks up your config file and your settings, which should sort out your problem

          J

          • 2. Re: Log4j problem.
            tewk

            I get class not found errors whenever I try to get the logger.
            java.lang.NoClassDefFoundError: org/apache/log4j/Logger

            I assume this is because the classloader for my ejb is different from the one used to create the log4j JMX MBean.
            How did you get around this

            • 3. Re: Log4j problem.

              Logger is in log4j 1.2 (still beta)

              JBoss uses log4j 1.1

              Regards,
              Adrian

              • 4. Re: Log4j problem.
                tewk

                Ok I got it to compile however the followin config file doesn't produce any log files

                # A log4j properties file suitable for replacing the
                # default JBoss ConsoleLogging & FileLogging mbeans.

                log4j.rootCategory=DEBUG, Default, Console

                log4j.catagory.ndsejb.ndnreaper=DEBUG, ndnreaper
                #log4j.additivity.catagory.ndsejb.ndnreaper=false

                log4j.catagory.ndsejb.ndnreaper.stats=DEBUG, ndnreaperstats
                #log4j.additivity.catagory.ndsejb.ndnreaper.stats=faslse

                log4j.catagory.ndsejb.ndnreaper.timings=DEBUG, ndnreapertimings
                #log4j.additivity.catagory.ndsejb.ndnreaper.timings=false

                ### The server.log file appender
                log4j.appender.Default=org.apache.log4j.RollingFileAppender
                log4j.appender.Default.File=../log/server.log
                log4j.appender.Default.MaxFileSize=500KB
                log4j.appender.Default.MaxBackupIndex=1
                log4j.appender.Default.layout=org.apache.log4j.PatternLayout
                # Use the default JBoss format
                log4j.appender.Default.layout.ConversionPattern=[%d{ABSOLUTE},%c{1}] %m%n
                # Truncate if it aleady exists.
                log4j.appender.Default.Append=false
                #Example of turning off logging for a category. Uncomment to turn off.
                #log4j.category.DefaultDS=FATAL

                ### The console appender
                log4j.appender.Console=org.jboss.logging.log4j.ConsoleAppender
                log4j.appender.Console.Threshold=INFO
                log4j.appender.Console.layout=org.apache.log4j.PatternLayout
                log4j.appender.Console.layout.ConversionPattern=[%p,%c{1}] %m%n

                # Example of only showing INFO msgs for any categories under org.jboss.util
                #log4j.category.org.jboss.util=INFO

                # An example of enabling the custom TRACE level priority that is used
                # by the JBoss internals to diagnose low level details. This example
                # turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
                # subpackages. This will produce A LOT of logging output.
                #log4j.category.org.jboss.ejb.plugins=TRACE#org.jboss.logging.TracePriority


                log4j.appender.nonreaper=org.apache.log4j.FileAppender
                log4j.appender.nonreaper.Append=false
                log4j.appender.nonreaper.File=../log/ndnreaper.log
                log4j.appender.ndnreaper.layout=org.apache.log4j.PatternLayout
                log4j.appender.ndnreaper.layout.ConversionPattern=[%d{ABSOLUTE},%c{1}] %m%n

                log4j.appender.ndnreaperstats=org.apache.log4j.FileAppender
                log4j.appender.ndnreaperstats.Append=false
                log4j.appender.ndnreaperstats.File=../log/ndnreaper.log
                log4j.appender.ndnreaperstats.layout=org.apache.log4j.PatternLayout
                log4j.appender.ndnreaperstats.layout.ConversionPattern=[%d{ABSOLUTE},%c{1}] %m%n

                log4j.appender.ndnreapertimings=org.apache.log4j.FileAppender
                log4j.appender.ndnreapertimings.Append=false
                log4j.appender.ndnreapertimings.File=../log/ndnreaper.log
                log4j.appender.ndnreapertimings.layout=org.apache.log4j.PatternLayout
                log4j.appender.ndnreapertimings.layout.ConversionPattern=[%d{ABSOLUTE},%c{1}] %m%n