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]>

Reply via email to