/**
* Logback: the reliable, generic, fast and flexible logging framework.
* Copyright (C) 1999-2009, QOS.ch. All rights reserved.
*
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation
*
* or (per the licensee's choosing)
*
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
package ch.qos.logback.classic.util;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.slf4j.spi.MDCAdapter;
/**
* A Mapped Diagnostic Context, or MDC in short, is an instrument for
* distinguishing interleaved log output from different sources. Log output is
* typically interleaved when a server handles multiple clients
* near-simultaneously.
*
* The MDC is managed on a per thread basis. A child thread
* automatically inherits a copy of the mapped diagnostic context of
* its parent.
*
*
* For more information about MDC, please refer to the online manual at
* http://logback.qos.ch/manual/mdc.html
*
* @author Ceki Gülcü
*/
public class LogbackMDCAdapter implements MDCAdapter {
// LBCLASSIC-183 has not yet been checked
final InheritableThreadLocal> currentThreadLocal = new InheritableThreadLocal>()
{
@SuppressWarnings("unchecked")
@Override
protected HashMap childValue(HashMap parentValue) {
if (parentValue == null) {
return null;
}
return super.childValue((HashMap)parentValue.clone());
}
};
final InheritableThreadLocal