4 Replies Latest reply on Jun 24, 2006 1:39 PM by Larry Wilson

    Convenience class not printing Log4J debug statements

    Larry Wilson Newbie

      I'm hoping someone brighter than me can figure this out...

      I have a convenience class, ApplicationUtil, that contains a few application-specific functions.

      In this case, my log4j.xml file contains the following:

       <category name="com.imcadmin.application.ApplicationUtil">
       <priority value="DEBUG" />
       <appender-ref ref="IMCADMINLOG" />
       </category>
      

      which apparently works, sort of, except that the logger.debug messages don't print. Yet logger.isDebugEnabled() returns true. I have many other classes that work just fine with debug - this is the first time I've seen this.

      Here's a cut/paste from the output of the application:

      19:32:00,027 INFO [ApplicationUtil] logger.isDebugEnabled() = true
      19:32:00,027 INFO [ApplicationUtil] ISDEBUGENABLED runScheduledJobOnThisServer(Service Opt Out Handler) called
      19:32:00,028 INFO [ApplicationUtil] TEST INFO runScheduledJobOnThisServer(Service Opt Out Handler) called
      19:32:00,029 WARN [ApplicationUtil] TEST WARN runScheduledJobOnThisServer(Service Opt Out Handler) called
      19:32:00,029 ERROR [ApplicationUtil] TEST ERROR runScheduledJobOnThisServer(Service Opt Out Handler) called
      19:32:00,029 FATAL [ApplicationUtil] TEST FATAL runScheduledJobOnThisServer(Service Opt Out Handler) called
      19:32:00,030 INFO [STDOUT] SYSTEMOUT runScheduledJobOnThisServer(Service Opt Out Handler) called
      


      You can clearly see that isDebugEnabled() returns true, yet there's no logger.debug output.

      Here's the code, stripped of comments and other functions:

      import org.apache.log4j.Logger;
      
      public class ApplicationUtil
      {
       static Logger logger = Logger.getLogger(ApplicationUtil.class);
      
       private ApplicationUtil()
       {
       }
      
       public static boolean runScheduledJobOnThisServer(
       String jobName, String serverName)
       {
       logger.info("logger.isDebugEnabled() = " + logger.isDebugEnabled());
       if (logger.isDebugEnabled())
       {
       logger.info("ISDEBUGENABLED runScheduledJobOnThisServer(" + jobName + ") called");
       }
       logger.debug("TEST DEBUG runScheduledJobOnThisServer(" + jobName + ") called");
       logger.info("TEST INFO runScheduledJobOnThisServer(" + jobName + ") called");
       logger.warn("TEST WARN runScheduledJobOnThisServer(" + jobName + ") called");
       logger.error("TEST ERROR runScheduledJobOnThisServer(" + jobName + ") called");
       logger.fatal("TEST FATAL runScheduledJobOnThisServer(" + jobName + ") called");
       System.out.println("SYSTEMOUT runScheduledJobOnThisServer(" + jobName + ") called");
       return true;
       }
      
      }
      


      Using 4.0.4.GA

      Any thoughts, impressions, suggestions, hints, etc. will be greatly appreciated.

      Larry