Top Description Fields Constructors Methods
ch.qos.logback.classic.sift

public Class MDCBasedDiscriminator

extends AbstractDiscriminator<ILoggingEvent>
Class Inheritance
Imports
ch.qos.logback.classic.spi.ILoggingEvent, ch.qos.logback.core.sift.AbstractDiscriminator, ch.qos.logback.core.util.OptionHelper, java.util.Map

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

Modifier and TypeField and Description
private String
private String
Inherited from ch.qos.logback.core.sift.AbstractDiscriminator:
started

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
public String
getDiscriminatingValue(ILoggingEvent event)

Implements ch.qos.logback.core.sift.Discriminator.getDiscriminatingValue.

Return the value associated with an MDC entry designated by the Key property.
public String
getKey()

Implements ch.qos.logback.core.sift.Discriminator.getKey.

The key or variable name under which the discriminating value should be exported into the host environment.
public void
setDefaultValue(String defaultValue)

The default MDC value in case the MDC is not set for mdcKey.

public void
public void
Inherited from ch.qos.logback.core.sift.AbstractDiscriminator:
isStartedstop

Field Detail

defaultValueback to summary
private String defaultValue
keyback to summary
private String key

Constructor Detail

MDCBasedDiscriminatorback to summary
public MDCBasedDiscriminator()

Method Detail

getDefaultValueback to summary
public String getDefaultValue()
See Also
setDefaultValue(String)
getDiscriminatingValueback to summary
public String getDiscriminatingValue(ILoggingEvent event)

Implements ch.qos.logback.core.sift.Discriminator.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.

getKeyback to summary
public String getKey()

Implements ch.qos.logback.core.sift.Discriminator.getKey.

Doc from ch.qos.logback.core.sift.Discriminator.getKey.

The key or variable name under which the discriminating value should be exported into the host environment.

setDefaultValueback to summary
public void setDefaultValue(String defaultValue)

The default MDC value in case the MDC is not set for mdcKey.

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.

setKeyback to summary
public void setKey(String key)
startback to summary
public void start()

Overrides ch.qos.logback.core.sift.AbstractDiscriminator.start.

Implements ch.qos.logback.core.spi.LifeCycle.start.

Annotations
@Override