Package ch.qos.logback.classic.sift
Class MDCBasedDiscriminator
java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.sift.AbstractDiscriminator<ILoggingEvent>
ch.qos.logback.classic.sift.MDCBasedDiscriminator
- All Implemented Interfaces:
Discriminator<ILoggingEvent>
,ContextAware
,LifeCycle
MDCBasedDiscriminator essentially returns the value mapped to an MDC key. If
the said value is null, then a default value is returned.
Both Key and the DefaultValue are user specified properties.
- Author:
- Ceki Gülcü
-
Field Summary
Fields inherited from class ch.qos.logback.core.sift.AbstractDiscriminator
started
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturn the value associated with an MDC entry designated by the Key property.getKey()
void
setDefaultValue
(String defaultValue) The default MDC value in case the MDC is not set formdcKey
.void
void
start()
Methods inherited from class ch.qos.logback.core.sift.AbstractDiscriminator
isStarted, stop
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
Constructor Details
-
MDCBasedDiscriminator
public MDCBasedDiscriminator()
-
-
Method Details
-
getDiscriminatingValue
Return the value associated with an MDC entry designated by the Key property. If that value is null, then return the value assigned to the DefaultValue property. -
start
public void start()- Specified by:
start
in interfaceLifeCycle
- Overrides:
start
in classAbstractDiscriminator<ILoggingEvent>
-
getKey
-
setKey
-
getDefaultValue
- Returns:
- See Also:
-
setDefaultValue
The default MDC value in case the MDC is not set formdcKey
.For example, if
Key
is set to the value "someKey", and the MDC is not set for "someKey", then this appender will use the default value, which you can set with the help of this method.- Parameters:
defaultValue
-
-