org.ops4j.pax.logging.PaxContext Maven / Gradle / Ivy
Show all versions of pax-logging-api Show documentation
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ops4j.pax.logging;
import java.util.HashMap;
import java.util.Map;
/**
* The MDC class that provides mapped diagnostic contexts.
*
* 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 (with normal
* {@link InheritableThreadLocal} child inherits the same references). That behavior can be switched
* off by setting the system property org.ops4j.pax.logging.threadContextMapInheritable to
* false (default is true).
*
* The MDC class requires JDK 1.2 or above. Under JDK 1.1 the MDC will always return empty
* values but otherwise will not affect or harm your application.
*
* @author Ceki Gülcü
* @since 1.2
*/
public class PaxContext {
static final int HT_SIZE = 7;
final ThreadLocal