2 Replies Latest reply on Mar 17, 2005 3:55 PM by mamemc

    log4j.xml - can't get trace logging to work

    berkgypsy

      I can't for the life of me figure out why I'm not getting trace messages logged to the error-server.log file. I do see that the threshold is set to "WARN" for the ERROR_FILE appender but when I take that out I get a bazillion DEBUG messages, and that's not what I want. Can someone please help me enabled trace logging JUST for the org.jboss.tm package? I've read many posts in this forum already and haven't been able to figure it out. Thanks

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
      
      <!-- ===================================================================== -->
      <!-- -->
      <!-- Log4j Configuration -->
      <!-- -->
      <!-- ===================================================================== -->
      
      <!-- $Id: log4j.xml,v 1.14 2002/08/09 22:55:25 user57 Exp $ -->
      
      <!--
      | For more configuration infromation and examples see the Jakarta Log4j
      | owebsite: http://jakarta.apache.org/log4j
       -->
      
      <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
      
      
       <!-- ============================== -->
       <!-- 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{2} %L] %m%n"/>
       </layout>
       </appender>
      
      
       <!-- ================================= -->
       <!-- Preserve messages in a local file -->
       <!-- ================================= -->
      
      
       <!-- A size based file rolling appender for scilearn classes -->
       <appender name="INFO_FILE" class="org.jboss.logging.appender.RollingFileAppender">
       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
       <param name="File" value="${jboss.server.home.dir}/log/info-server.log"/>
       <param name="Threshold" value="INFO"/>
       <param name="Append" value="false"/>
       <param name="MaxFileSize" value="5000KB"/>
       <param name="MaxBackupIndex" value="9"/>
      
       <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="%d %-5p [%c{2} %L] %m%n"/>
       </layout>
       </appender>
      
      
       <appender name="ERROR_FILE" class="org.jboss.logging.appender.RollingFileAppender">
       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
      
       <param name="File" value="${jboss.server.home.dir}/log/error-server.log"/>
       <param name="Threshold" value="WARN"/>
       <param name="Append" value="false"/>
       <param name="MaxFileSize" value="5000KB"/>
       <param name="MaxBackupIndex" value="2"/>
      
       <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="%d %-5p [%c{2} %L] %m%n"/>
       </layout>
       </appender>
      
      
       <!-- ====================== -->
       <!-- More Appender examples -->
       <!-- ====================== -->
      
       <!-- Buffer events and log them asynchronously -->
       <!--
       <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
       <appender-ref ref="INFO_FILE"/>
       <appender-ref ref="ERROR_FILE"/>
       <appender-ref ref="CONSOLE"/>
       </appender>
       -->
      
      
      
       <!-- ================ -->
       <!-- Limit categories -->
       <!-- ================ -->
      
       <category name="org.jboss.tm">
       <priority value="TRACE" class="org.jboss.logging.XLevel"/>
       </category>
      
      
       <!-- ======================= -->
       <!-- Setup the Root category -->
       <!-- ======================= -->
      
       <root>
       <appender-ref ref="CONSOLE"/>
       <appender-ref ref="INFO_FILE"/>
       <appender-ref ref="ERROR_FILE"/>
       </root>
      
      </log4j:configuration>
      


        • 1. Re: log4j.xml - can't get trace logging to work
          starksm64

          You need to read the log4j docs as your logic here is flawed. You cannot have a threshold that explicitly excludes the log level you want. To reduce the logging from non tm categories you need to add something like:

           <category name="org.jboss">
           <priority value="INFO" />
           </category>
          



          • 2. Re: log4j.xml - can't get trace logging to work
            mamemc

            Try setting up a new appender (TRACEFILE in this example) with a threshold of TRACE (or no threshold at all), and then changing the category filter to send your trace output to this appender. It will be in a different file of course, but it should be limit TRACE to the org.jboss.tm tree. It won't eliminate DEBUG messages from the file, but you can easily grep out the TRACE lines from the TRACEFILE.

             <category name="org.jboss.tm" additivity="false">
             <priority value="TRACE" class="org.jboss.logging.XLevel"/>
             <appender-ref ref="TRACEFILE"/>
             </category>