You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Ceki Gülcü <ce...@qos.ch> on 2004/09/28 16:14:48 UTC

Re: LevelMatchFilter does not work

You probably need a deny all filter at the end of the filter list.

At 05:09 PM 9/28/2004, you wrote:

>Hi all,
>
>I have problems to get the LevelMatchFilter work.
>
>I use a xml file to configure log4j
>
><?xml version="1.0" encoding="UTF-8" ?>
><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
>
><log4j:configuration>
>
><appender name="A1" class="org.apache.log4j.ConsoleAppender">
>       <param name="Threshold" value="DEBUG"/>
>       <layout class="org.apache.log4j.SimpleLayout">
>       </layout>
></appender>
>
><appender name="A2" class="org.apache.log4j.FileAppender">
>       <param name="file" value="C:/temp/test.log"/>
>       <param name="Append" value="true"/>
>       <param name="Threshold" value="DEBUG"/>
>       <layout class="org.apache.log4j.SimpleLayout">
>       </layout>
>       <filter class="org.apache.log4j.varia.LevelMatchFilter">
>             <param name="LevelToMatch" value="ERROR"/>
>             <param name="AcceptOnMatch" value="true"/>
>       </filter>
></appender>
>
><root>
>       <priority value ="DEBUG" />
>       <appender-ref ref="A2"/>
>       <appender-ref ref="A1"/>
></root>
>
></log4j:configuration>
>
>After that I thougt only log messages with level "ERROR" should be logged
>into test.log, but still all messages are in the console as well as in the
>file.
>
>I also tried it by programmatic configuration:
>
>       LevelMatchFilter myFilter = new LevelMatchFilter();
>       myFilter.setLevelToMatch(Level.ERROR.toString());
>       myFilter.setAcceptOnMatch(true);
>       myFilter.activateOptions();
>
>       RollingFileAppender myApp = new RollingFileAppender();
>       myApp.setName("TESTAPP");
>       myApp.setMaxFileSize("10MB");
>       myApp.setMaxBackupIndex(5);
>       myApp.setFile("c:/temp/test.log");
>       myApp.setLayout(new org.apache.log4j.SimpleLayout());
>       myApp.clearFilters();
>       myApp.addFilter(myFilter);
>       myApp.setThreshold(Level.DEBUG);
>       myApp.activateOptions();
>
>       Logger myLogger = Logger.getLogger("just.to.test");
>       myLogger.addAppender(myApp);
>       myLogger.setLevel(Level.DEBUG);
>
>But still the same result ... all log messages are logged to the file.
>
>So, please can someone give me a hint what is wrong in my Filter
>configuration ...
>
>Thanks a lot in advance ...
>
>Herb
>
>
>--
>Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
>Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail
>irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und
>vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte
>Weitergabe dieser Mail oder von Teilen dieser Mail ist nicht gestattet.
>
>Wir haben alle verkehrsüblichen Maßnahmen unternommen, um das Risiko der
>Verbreitung virenbefallener Software oder E-Mails zu minimieren, dennoch
>raten wir Ihnen, Ihre eigenen Virenkontrollen auf alle Anhänge an dieser
>Nachricht durchzuführen. Wir schließen außer für den Fall von Vorsatz oder
>grober Fahrlässigkeit die Haftung für jeglichen Verlust oder Schäden durch
>virenbefallene Software oder E-Mails aus.
>
>Jede von der Bank versendete E-Mail ist sorgfältig erstellt worden, dennoch
>schließen wir die rechtliche Verbindlichkeit aus; sie kann nicht zu einer
>irgendwie gearteten Verpflichtung zu Lasten der Bank ausgelegt werden.
>______________________________________________________________________
>
>This e-mail may contain confidential and/or privileged information. If you
>are not the intended recipient (or have received this e-mail in error)
>please notify the sender immediately and destroy this e-mail. Any
>unauthorised copying, disclosure or distribution of  the material in this
>e-mail or of parts hereof is strictly forbidden.
>
>We have taken precautions to minimize the risk of transmitting software
>viruses but nevertheless advise you to carry out your own virus checks on
>any attachment of this message. We accept no liability for loss or damage
>caused by software viruses except in case of gross negligence or willful
>behaviour.
>
>Any e-mail messages from the Bank are sent in good faith, but shall not be
>binding or construed as constituting any kind of obligation on the part of
>the Bank.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org

-- 
Ceki Gülcü

      For log4j documentation consider "The complete log4j manual"
      ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp  



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org