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ü <cg...@qos.ch> on 2001/02/20 11:59:46 UTC

Re: Filter problem



Venugopal,

Unfortunately, you cannot define filters in property files. You need to use XML. Sorry. Have you looked at the Threshold option? 


This is from the FAQ:

Is it possible to direct log output to different appenders by priority?
=======================================================================

Yes it is. Setting the Threshold option of any appender extending AppenderSkeleton, (most log4j appenders extend AppenderSkeleton) to filter out all log events with lower priority than the value of the threshold option. 

For example, setting the threshold of an appender to DEBUG also allow INFO, WARN, ERROR and FATAL messages to log along with DEBUG messages. (DEBUG is the lowest priority). This is usually acceptable as there is little use for DEBUG messages without the surrounding INFO, WARN, ERROR and FATAL messages. Similarly, setting the threshold of an appender to ERROR will filter out DEBUG, INFO and ERROR
messages but not FATAL messages. 

This policy usually best encapsulates what the user actually wants to do, as opposed to her mind-projected solution. 

See sort4.lcf for an example threshold configuration. 

If you must filter events by exact priority match, then you can attach a PriorityMatchFilter to any appender to filter out logging events by exact priority match. 

I hope this helps, Ceki

ps: Please continue this discussion in the log4j-user list not log4j-dev! 

At 15:46 20.02.2001 +0530, you wrote:
>Hi..
>I want a log messages whose prority exactly matches a particular proirty
>should to written into a particular Appender
>for examples:
> i want to write all error message to appender A1,
>              all warn message to appender A2 etc..
>I want this to configure in configaration file i.e., in a normal text
>file(Not Xml file)
>
>i tried out the following,but it is not working
>
>log4j.appender.A2=org.apache.log4j.FileAppender
>log4j.appender.A2.File=example1.log
>log4j.appender.A2.layout=org.apache.log4j.PatternLayout
>
>log4j.appender.A2.layout.ConversionPattern=%d{dd/MMM  HH:mm:ss}  %-5p:
>%-25C{3}[%-M]%3x      %-m%n
>log4j.appender.A2.Filter=org.apache.log4j.varia.PriorityMatchFilter
>log4j.appender.A2.Filter.PriorityToMatch="WARN"
>log4j.appender.A2.Filter.AcceptOnMatch=true
>
>please any one write a correct solution for this....
>
>Regards
>Venugopal Siripuram
>****************************************************************************
>*********************************

----
Ceki Gülcü          Web:   http://qos.ch      
av. de Rumine 5     email: cgu@qos.ch (preferred)
CH-1005 Lausanne           ceki_gulcu@yahoo.com
Switzerland         Tel: ++41 21 351 23 15