Having just written a test case for the LevelMatchFilter, I believe that its
behavior is to accept ONLY the level you have specified.  So, in the first
appender, only DEBUG messages will be captured.  You will be out of luck if
you want debug or above.

You can look at using the LevelRangeFilter class instead, but I think the
better solution is to set the threshold property of the appenders similar to
this:

<appender name="file" class="org.apache.log4j.FileAppender">
    [all the specific file appender/layout settings go here]
    <param name="threshold" value="DEBUG"/>
</appender>

<appender name="console" class="org.apache.log4j.ConsoleAppender">
    [all the specific console appender/layout settings go here]
    <param name="threshold" value="INFO"/>
</appender>

<logger name="uk.co.his.eop">
    <appender-ref ref="file"/>
    <appender-ref ref="console">
</logger>

hope it helps,
-Mark

> -----Original Message-----
> From: Jeffrey Winter [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 10, 2002 9:49 AM
> To: Log4J Users List
> Subject: Re: Problems with multiple (same) categories, but diff
> prioritys
> 
> 
> First off, I believe the way you've defined things is causing 
> the second
> <logger> to 'overwrite' the first <logger> since they have 
> the same name.
> 
> Second, you can easily do what you want by defining 2 
> appenders on that
> logger with filters:
> 
> 
> <appender name="file" class="org.apache.log4j.FileAppender">
>     <filter class="org.apache.log4j.varia.LevelMatchFilter">
>       <param name="LevelToMatch" value="DEBUG"/>
>       <param name="AcceptOnMatch" value="true"/>
>     </filter>
>     <filter class="org.apache.log4j.varia.DenyAllFilter"/>
> </appender>
> 
> <appender name="console" class="org.apache.log4j.ConsoleAppender">
>     <filter class="org.apache.log4j.varia.LevelMatchFilter">
>       <param name="LevelToMatch" value="INFO"/>
>       <param name="AcceptOnMatch" value="true"/>
>     </filter>
>     <filter class="org.apache.log4j.varia.DenyAllFilter"/>
> </appender>
> 
> <logger name="uk.co.his.eop">
>     <appender-ref ref="file"/>
>     <appender-ref ref="console">
> </logger>
> 
> ----- Original Message -----
> From: "Julian Kite" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, May 10, 2002 12:20 PM
> Subject: Problems with multiple (same) categories, but diff prioritys
> 
> 
> Hi,
> 
>  Does anyone know how I can use the DOM based configuration to do the
> following?
> 
> My application logs to a Class name based category i.e.
> 'uk.co.his.eop.????"
> 
> I want to
> 
> 1.  Put all DEBUG and above messages to a file
> 2.  Put all INFO and above messages to the console
> 
> If I set up to the two logger/category elements with the same name the
> second is ignored, but I can only specify the
> Level inside a logger/category element.
> 
> This is what I mean (I've removed details of the appenders, for
> clarity):
> 
>       <logger name="uk.co.his.eop ">
>         <level value="DEBUG"></level>
>         <appender-ref ref="file"></appender-ref>
>       </logger>
> 
>       <logger name="uk.co.his.eop ">
>         <level value="INFO"></level>
>         <appender-ref ref="console"></appender-ref>
>       </logger>
> 
> In this case the file shows nothing(empty) and the console shows
> everything of INFO and above!
> 
> If I swap them around - i.e.
> 
> 
>       <logger name="uk.co.his.eop ">
>         <level value="INFO"></level>
>         <appender-ref ref="console"></appender-ref>
>       </logger>
> 
>       <logger name="uk.co.his.eop ">
>         <level value="DEBUG"></level>
>         <appender-ref ref="file"></appender-ref>
>       </logger>
> 
> The console shows nothing and the file shows everything of DEBUG and
> above!
> 
> 
> What I am attempting to do seems quite simple and typical for logging
> purposes.
> 
> Any ideas?
> 
> Thanks in advance for any help!
> 
> Cheers Julian Kite
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 

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

Reply via email to