Details
-
Bug
-
Resolution: Fixed
-
Major
-
0.9.21
-
None
Description
In MDCBasedDiscriminator.getDiscriminatingValue() the MDC of the current thread is referenced:
public String getDiscriminatingValue(ILoggingEvent event) {
String mdcValue = MDC.get(key);
if (mdcValue == null)
else
{ return mdcValue; }}
This doesn't work is the logging events are serialized and processed in a different thread or JVM.
Instead using SLF4Js MDC class why not using ILoggingEvent.getMdc() to access the MDC or a serialized version of it?
Maybe something like this:
public String getDiscriminatingValue(ILoggingEvent event) {
if (event != null) {
String mdcValue = event.getMdc().get(getKey());
if (mdcValue != null)
}
return getDefaultValue();
}
Right now we have to workaround this by creating our own version of DeferedMDCBasedDiscriminator
Some like this:
public class DeferedMDCBasedDiscriminator extends MDCBasedDiscriminator {
public String getDiscriminatingValue(ILoggingEvent event) {
if (event != null) {
String mdcValue = event.getMdc().get(getKey());
if (mdcValue != null) { return mdcValue; }
}
return getDefaultValue();
}
}