Log4j Message Filtering
Some Notes on built in filtering facility
http://logging.apache.org/log4j/1.2/...tchFilter.html
org.apache.log4j.varia.StringMatchFilter - this is a "contains" match paradigm.
Followup: This actually uses the indexOf method for matching, so it acts like a "contains" match, and IS CaseSensitive.
possible specification in an appender tag
extend from an example at http://stackoverflow.com/questions/4...-the-log4j-xml
NOTE: THIS IS UNTESTED YET.
<filter class="org.apache.log4j.varia.StringMatchFilter">
<!-- skip messages from this class -->
<param name="StringToMatch" value="my.co.package.class" />
<param name="AcceptOnMatch" value="FALSE" />
</filter>
Source Ref:
http://javasourcecode.org/html/open-...lter.java.html
log4j.dtd excerpt
There is also a LogfilePatternReciever that can tail or parse a log file and create events. Don't know much about how that works. It only uses a simple * as a wildcard pattern.
http://logging.apache.org/log4j/comp...nReceiver.html
http://logging.apache.org/log4j/1.2/...tchFilter.html
org.apache.log4j.varia.StringMatchFilter - this is a "contains" match paradigm.
Followup: This actually uses the indexOf method for matching, so it acts like a "contains" match, and IS CaseSensitive.
possible specification in an appender tag
extend from an example at http://stackoverflow.com/questions/4...-the-log4j-xml
NOTE: THIS IS UNTESTED YET.
<filter class="org.apache.log4j.varia.StringMatchFilter">
<!-- skip messages from this class -->
<param name="StringToMatch" value="my.co.package.class" />
<param name="AcceptOnMatch" value="FALSE" />
</filter>
Source Ref:
http://javasourcecode.org/html/open-...lter.java.html
log4j.dtd excerpt
Code:
<!-- Appenders must have a name and a class. --> <!-- Appenders may contain an error handler, a layout, optional parameters --> <!-- and filters. They may also reference (or include) other appenders. --> <!ELEMENT appender (errorHandler?, param*, layout?, filter*, appender-ref*)>
There is also a LogfilePatternReciever that can tail or parse a log file and create events. Don't know much about how that works. It only uses a simple * as a wildcard pattern.
http://logging.apache.org/log4j/comp...nReceiver.html
Total Comments 0