Class MDC
- Namespace
- log4net
- Assembly
- log4net.dll
Implementation of Mapped Diagnostic Contexts.
public sealed class MDC
- Inheritance
-
MDC
- Inherited Members
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.
Methods
Clear()
Clear all entries in the MDC
public static void Clear()
Remarks
note
The MDC is deprecated and has been replaced by the Properties.
The current MDC implementation forwards to the ThreadContext.Properties.
Remove all the entries from this thread's MDC
Get(string)
Gets the context value identified by the key parameter.
public static string Get(string key)
Parameters
keystringThe key to lookup in the MDC.
Returns
- string
The string value held for the key, or a
nullreference if no corresponding value is found.
Remarks
note
The MDC is deprecated and has been replaced by the Properties.
The current MDC implementation forwards to the ThreadContext.Properties.
If the key parameter does not look up to a
previously defined context then null will be returned.
Remove(string)
Removes the key value mapping for the key specified.
public static void Remove(string key)
Parameters
keystringThe key to remove.
Remarks
note
The MDC is deprecated and has been replaced by the Properties.
The current MDC implementation forwards to the ThreadContext.Properties.
Remove the specified entry from this thread's MDC
Set(string, string)
Add an entry to the MDC
public static void Set(string key, string value)
Parameters
Remarks
note
The MDC is deprecated and has been replaced by the Properties.
The current MDC implementation forwards to the ThreadContext.Properties.
Puts a context value (the value parameter) as identified
with the key parameter into the current thread's
context map.
If a value is already defined for the key
specified then the value will be replaced. If the value
is specified as null then the key value mapping will be removed.