[logback-dev] [JIRA] Resolved: (LBCLASSIC-213) SiftingAppenders MDCBasedDiscriminator does not support deferred processing of LoggingEvents

Ceki Gulcu (JIRA) noreply-jira at qos.ch
Tue Jun 29 15:41:16 CEST 2010


     [ http://jira.qos.ch/browse/LBCLASSIC-213?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ceki Gulcu resolved LBCLASSIC-213.
----------------------------------

    Fix Version/s: 0.9.23
       Resolution: Fixed

Thank you for this report. The issue has been solved in release 0.9.23.

> SiftingAppenders MDCBasedDiscriminator does not support deferred processing of LoggingEvents
> --------------------------------------------------------------------------------------------
>
>                 Key: LBCLASSIC-213
>                 URL: http://jira.qos.ch/browse/LBCLASSIC-213
>             Project: logback-classic
>          Issue Type: Bug
>          Components: appender
>    Affects Versions: 0.9.21
>            Reporter: Torsten Juergeleit
>            Assignee: Ceki Gulcu
>             Fix For: 0.9.23
>
>
> In MDCBasedDiscriminator.getDiscriminatingValue() the MDC of the current thread is referenced:
>   public String getDiscriminatingValue(ILoggingEvent event) {
>     String mdcValue = MDC.get(key);
>     if (mdcValue == null) {
>       return defaultValue;
>     } 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 mdcValue;
> 			}
> 		}
> 		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();
> 	}
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the logback-dev mailing list