MDC Class | Apache log4net™ SDK Documentation

Implementation of Mapped Diagnostic Contexts.
Inheritance Hierarchy

System
Object
log4net
MDC

Namespace: log4net
Assembly: log4net (in log4net.dll) Version: 2.0.8.0-.NET 4.0
Syntax

C#
VB
C++
F#
Copy

    public sealed class MDC

    Public NotInheritable Class MDC

    public ref class MDC sealed

    [<SealedAttribute>]
    type MDC =  class end

The MDC type exposes the following members.

Methods

| Name | Description
--- | --- | ---
| Clear | Clear all entries in the MDC
| Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
| Get | Gets the context value identified by the key parameter.
| GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
| GetType | Gets the Type of the current instance. (Inherited from Object.)
| Remove | Removes the key value mapping for the key specified.
| Set | Add an entry to the MDC
| ToString | Returns a String that represents the current Object. (Inherited from Object.)

Top
Remarks

Note
The MDC is deprecated and has been replaced by the Properties. The current MDC implementation forwards to the ThreadContext.Properties.

The MDC class is similar to the NDC class except that it is based on a map instead of a stack. It 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.

Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.
See Also

#### Reference

log4net Namespace