views:

4619

answers:

2

Let me preface this question by saying I've exhausted Google, or at least what I've been trying to search for. "log4j threshold", "log4j threshold category", "log4j appender threshold category", etc. But I really don't understand the results I'm getting back from Google.

This is the full configuration I've been given. I can't figure out how to modify it to suit my needs.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<!-- ===================================================================== -->
<!--                                                                       -->
<!--  Log4j Configuration                                                  -->
<!--                                                                       -->
<!-- ===================================================================== -->

<!-- $Id: jboss-log4j.xml 62403 2007-04-18 15:26:43Z [email protected] $ -->

<!--
| 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">

<!-- ================================= -->
<!-- Preserve messages in a local file -->
<!-- ================================= -->

<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">
     <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="DEBUG"/>

  <layout class="org.apache.log4j.PatternLayout">
     <!-- The default pattern: Date Priority [Category] Message\n -->
     <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c] %m%n"/>
  </layout>
</appender>



<!-- ================ -->
<!-- Limit categories -->
<!-- ================ -->

<category name="com.arjuna">
  <priority value="FATAL"/>
</category>   

<category name="com.sun.facelets">
  <priority value="ERROR"/>
</category>   

 <category name="jacorb">
   <priority value="FATAL"/>
 </category>

<category name="javax.enterprise.resource">
  <priority value="WARNING"/>
 </category>  

 <category name="javax.enterprise.resource.webcontainer.jsf">
    <priority value="WARNING"/>
 </category>  

 <category name="org.apache">
    <priority value="FATAL"/>
 </category>

 <category name="org.hibernate">
    <priority value="FATAL"/>
 </category>   

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

<category name="org.jboss.ejb3.EJB3Deployer">
 <priority value="WARNING" />
</category>

<category name="org.jboss.ejb3.JmxKernelAbstraction">
 <priority value="WARNING" />
</category>

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

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

<category name="org.jboss.wsf.framework">
   <priority value="FATAL"/>
</category>   

<category name="org.jgroups">
   <priority value="FATAL"/>
</category>

<category name="org.quartz">
 <priority value="FATAL" />
</category>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->

<root>
   <appender-ref ref="CONSOLE"/>
   <appender-ref ref="FILE"/>
</root>



</log4j:configuration>

I don't understand how the appender's "threshold" level interacts with the categories. See, I only want com.foo.bar messages to show on the console. But it seems like I'm getting a lot more than that, for instance, org.jboss.wsf.framework is dumping out DEBUG messages, even though I have a category with a name that matches it and set to FATAL.

I'm certain I'm manipulating the correct config file, as jboss reports it's reloading the config after I change it. So how do I set the category/threshold levels right? What's the difference between the threshold and category?

Example output (snipped). Why does quartz show up on the console when I have it set to FATAL?

2009-06-22 00:58:37,666 INFO  [org.quartz.plugins.history.LoggingJobHistoryPlugin] Job JobInitializationPlugin.JobInitializationPlugin_jobInitializer execution complete at  00:58:37 06/22/2009 and reports: null
2009-06-22 01:08:37,669 DEBUG [org.quartz.simpl.SimpleJobFactory] Producing instance of Job 'JobInitializationPlugin.JobInitializationPlugin_jobInitializer', class=org.quartz.jobs.FileScanJob
2009-06-23 15:44:17,790 INFO  [org.jboss.wsf.stack.jbws.NativeServerConfig] 3.0.5.GA
2009-06-23 15:44:17,868 DEBUG [org.jboss.wsf.framework.deployment.DeploymentAspectManagerImpl] setDeploymentAspects on WSDeploymentAspectManagerEJB
2009-06-23 15:44:17,868 DEBUG [org.jboss.wsf.framework.deployment.DeploymentAspectManagerImpl] setDeploymentAspects on WSDeploymentAspectManagerEndpointAPI
A: 
James A. N. Stauffer
I updated the question with the full config and some of the example output of what I'm talking about.
yodaj007
Just because JBoss reloads it doesn't mean that it is what is used. See debug to true for the root element of log4j and the output may help you see what is going wrong.
James A. N. Stauffer
+1  A: 

To answer the specific question of why does Quartz show up on the logging, you would have to change the Quartz configuration as follows:

 <category name="org.quartz" additivity="false">
    <priority value="FATAL" />
 </category>

The additivity attribute tells log4j to override the root setting and use this only for org.quartz.

In a previous version of the question you stated you only wanted those messages from those classes turned on, to do that you have to start with configuring the priority in the root element to fatal (or even NO) and then it will only log those packages/classes that you turn on explicitly.

To answer your question about how threshold interacts with category, basically think of it is as a publish/subscribe. The category sets what is published by the logger, the threshold sets the subscription level of the appender.

This is complicated slightly be the fact that category is not a single thing, but rather a hierarchy, so the fact that you set the publishing level on one category isn't the whole story. It may be overridden in the hierarchy, as it was in your case.

Yishai
Thank you so much!
yodaj007