com.sonicsw.esb.service.common.util
Class MDCFilter
java.lang.Object
org.apache.log4j.spi.Filter
com.sonicsw.esb.service.common.util.MDCFilter
- All Implemented Interfaces:
- org.apache.log4j.spi.OptionHandler
public class MDCFilter
- extends org.apache.log4j.spi.Filter
Log filter that denies log events unless a specified name/value pair is set
in the mapped diagnostic context for the current thread.
There are two modes of operation:
- If the
required
property is true
(as it is
by default) then log events are denied unless the specified
key/value
pair exists in the MDC.
- If the
required
property is false
then log
events are denied only if the specified key
exists in the MDC
with a non-matching value
. In this mode log events are
allowed if the MDC has no entry for the given key.
Filters can be configured using an XML log4j configuration file. For example,
the following configuration filters out any log messages not produced by
MyServiceInstance
:
<appender name="xqLog" class="org.apache.log4j.ConsoleAppender">
<layout> ... </layout>
<filter class="com.sonicsw.esb.service.common.util.MDCFilter">
<param name="key" value="service"/>
<param name="value" value="MyServiceInstance"/>
</filter>
</appender>
- See Also:
MDC
Fields inherited from class org.apache.log4j.spi.Filter |
ACCEPT, DENY, NEUTRAL, next |
Methods inherited from class org.apache.log4j.spi.Filter |
activateOptions, getNext, setNext |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MDCFilter
public MDCFilter()
decide
public int decide(org.apache.log4j.spi.LoggingEvent event)
- Specified by:
decide
in class org.apache.log4j.spi.Filter
getKey
public java.lang.String getKey()
setKey
public void setKey(java.lang.String key)
getValue
public java.lang.String getValue()
setValue
public void setValue(java.lang.String value)
isRequired
public boolean isRequired()
setRequired
public void setRequired(boolean required)
isInvert
public boolean isInvert()
setInvert
public void setInvert(boolean invert)
Copyright © 2001-2013 Aurea, Inc. All Rights Reserved.
HTML formatted on 29-April-2013.