1 Reply Latest reply on Aug 29, 2009 12:02 PM by Peter Johnson

    I can't log my application with DEBUG level

    Marco De Simone Newbie

      Hi forum.

      I've a deployed war into my JBoss 4.2.2 GA.
      I want to use the external jboss-log4j.xml for my appenders and category.

      So, this is my new configuration file.

      
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
      
      
      <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
      
       <!-- ================================= -->
       <!-- Preserve messages in a local file -->
       <!-- ================================= -->
      
       <!-- A time/date based rolling appender -->
       <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
       <param name="File" value="${jboss.server.log.dir}/server.log"/>
       <param name="Append" value="false"/>
      
       <!-- Rollover at midnight each day -->
       <param name="DatePattern" value="'.'yyyy-MM-dd"/>
      
       <layout class="org.apache.log4j.PatternLayout">
       <!-- The default pattern: Date Priority [Category] Message\n -->
       <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
      
       </layout>
       </appender>
      
      
       <!-- ============================== -->
       <!-- Append messages to the console -->
       <!-- ============================== -->
      
       <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
       <param name="Target" value="System.out"/>
       <param name="Threshold" value="INFO"/>
      
       <layout class="org.apache.log4j.PatternLayout">
       <!-- The default pattern: Date Priority [Category] Message\n -->
       <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
       </layout>
       </appender>
      
      
       <appender name="sicrelAppender" class="org.jboss.logging.appender.DailyRollingFileAppender">
       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
       <param name="File" value="${jboss.server.log.dir}/sicrel.log"/>
       <param name="Append" value="false"/>
       <param name="Threshold" value="DEBUG"/>
      
       <!-- Rollover at midnight each day -->
       <param name="DatePattern" value="'.'yyyy-MM-dd"/>
      
       <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
       </layout>
      
       <filter class="org.jboss.logging.filter.TCLFilter">
       <param name="AcceptOnMatch" value="true"/>
       <param name="DeployURL" value="sicrel.war"/>
       </filter>
       </appender>
      
      
       <!-- ================ -->
       <!-- Limit categories -->
       <!-- ================ -->
      
       <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
       <category name="org.apache">
       <priority value="INFO"/>
       </category>
      
       <!-- Limit the jacorb category to WARN as its INFO is verbose -->
       <category name="jacorb">
       <priority value="WARN"/>
       </category>
      
       <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
       <category name="org.jgroups">
       <priority value="WARN"/>
       </category>
      
       <!-- Limit the org.quartz category to INFO as its DEBUG is verbose -->
       <category name="org.quartz">
       <priority value="INFO"/>
       </category>
      
       <!-- Limit the JSR77 categories -->
       <category name="org.jboss.management">
       <priority value="INFO"/>
       </category>
      
      
       <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->
       <category name="org.jboss.serial">
       <priority value="INFO"/>
       </category>
      
      
       <root>
       <appender-ref ref="CONSOLE"/>
       <appender-ref ref="FILE"/>
       <appender-ref ref="sicrelAppender"/>
       </root>
      
      </log4j:configuration>
      
      


      Into my application sicrel.war there is the following ProjectLogger class.

      public final class ProjectLogger {
      
       private final static Logger LOGGER;
      
       static {
       LOGGER = Logger.getLogger("");
      
       }
      
       public static Logger getLogger() {
       return LOGGER;
       }
      }
      
      
      


      while into a generic servlet there are these pieces of code

      
      /* (1) */
       if (ProjectLogger.getLogger().isDebugEnabled()){
       ProjectLogger.getLogger().debug("Start");
       }
      /* (2) */
       if (ProjectLogger.getLogger().isDebugEnabled()){
       ProjectLogger.getLogger().info("request.getRequestURI() "+request.getRequestURI());
      }
      
      


      Well, with
      <param name="Threshold" value="INFO"/>
      

      into the sicrelAppender,

      the sicrel.log contains the jboss startup logs too,
      and the (2) log code of my application (even if under the isDebugEnabled() !)

      with
      <param name="Threshold" value="DEBUG"/>
      

      into the sicrelAppender,

      the two files, server.log and sicrel.log are identical.
      Besides, only the (2) log code is written too.

      So, the questions are:

      1) why the sicrel.war and JBoss logs are merged into sicrel.log even if the sicrelAppender has a configured filter?
      2) why the .info() log is written even if under isDebugEnabled()?
      3) why the .debug() log is never written?


      Thanks in advance