Here's my log4j.xml file, with irrelevant stuff removed.
The trick is to play with the different filters and how
they are chained.  The filters seem to be checked 
in the order configured in the appender element, until
one is found that says "accept" or that says "deny."
(as opposed to saying "neutral.")

So my first filter says, "accept a particular level", 
my second filter says, "deny all levels" that weren't already
accepted.

Note: I am still running 1.0.4 but this should work with
the newer versions.  Also if you're running a newer version,
you also have PriorityRangeFilter.

--
Bart Blacha, Software Developer
NetPerceptions Inc.
(512) 349-5622
[EMAIL PROTECTED]
 


<configuration>
   <appender name="DebugFiles" class="org.apache.log4j.RollingFileAppender">
      <param name="File" value="log/debug.log" />
      <filter class="org.apache.log4j.varia.PriorityMatchFilter">
                  <param name="PriorityToMatch" value="DEBUG" />
                  <param name="AcceptOnMatch" value="true" />
      </filter>
      <filter class="org.apache.log4j.varia.DenyAllFilter">
      </filter>
   </appender>

   <appender name="ErrorFiles" class="org.apache.log4j.RollingFileAppender">
      <param name="File" value="log/error.log" />
      <filter class="org.apache.log4j.varia.PriorityMatchFilter">
                  <param name="PriorityToMatch" value="ERROR" />
                  <param name="AcceptOnMatch" value="true" />
      </filter>
      <filter class="org.apache.log4j.varia.DenyAllFilter">
      </filter>
   </appender>

   <root>
      <priority value ="debug" />
      <appender-ref ref="DebugFiles" />
      <appender-ref ref="ErrorFiles" />
   </root>
</configuration>




> -----Original Message-----
> From: Perry Hoekstra [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 26, 2001 8:38 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Assigning appenders to priorities?
> 
> 
> Okay, how did you do it??
> 
> I am struggling with the same issue.  I defined my two 
> appenders like so:
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> 
> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/";>
>       <appender name="weblogic" 
> class="com.medtronic.weblogic.WebLogicLogAppender">
>       
>               <layout class="org.apache.log4j.TTCCLayout">
>                 <param name="DateFormat" value="ISO8601" />
>               </layout>       
>       </appender>
>                               
>       <appender name="log_debug" 
> class="org.apache.log4j.FileAppender">
>               <param name="File" 
> value="config/internet/logs/debug.log" />
>               <param name="Append" value="false" />
>               
>               <layout class="org.apache.log4j.TTCCLayout">
>                 <param name="DateFormat" value="ISO8601" />
>               </layout>                                       
>       </appender>
>       
>       <root>
>               <priority value="info"/>
>               <appender-ref ref="weblogic"/>
>       </root>
>       
>       <category name="com.foo.app">
>         <appender-ref ref="log_debug" />
>       </category>
> </log4j:configuration>
> 
> I looked at the <PriorityToMatch> but reading the JavaDoc on it:
> 
> If there is an exact match between the value of the PriorityToMatch 
> option and the priority of the {@link LoggingEvent}, then the {@link 
> #decide} method returns {@link Filter#ACCEPT}
> 
> it looks like a one-to-one rather than >= where it would accept the 
> current level and anything higher.  Do you have to create an 
> <appender> 
> entry for each level (ERROR, WARN, INFO)?
> 
> Yes, I did read the documentation on Appender addivity but I 
> believe my 
> problem relates more to getting the XML config file created correctly.
> 
> -- 
> Perry Hoekstra
> E-Commerce Architect
> Talent Software Services
> [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to