log4net SDK Reference |

# NDC Class

Implementation of Nested Diagnostic Contexts.

For a list of all members of this type, see NDC Members.

System.Object
log4net.NDC

[Visual Basic]
NotInheritable Public Class NDC
[C#]
public sealed class NDC

#### Thread Safety

This type is safe for multithreaded operations.

#### Remarks

> Note

> The NDC is deprecated and has been replaced by the Stacks. The current NDC implementation forwards to the `ThreadContext.Stacks["NDC"]`.

A Nested Diagnostic Context, or NDC in short, is an instrument to distinguish interleaved log output from different sources. Log output is typically interleaved when a server handles multiple clients near-simultaneously.

Interleaved log output can still be meaningful if each log entry from different contexts had a distinctive stamp. This is where NDCs come into play.

Note that NDCs are managed on a per thread basis. The NDC class is made up of static methods that operate on the context of the calling thread.

#### Example

How to push a message into the context

    [C#]
    using(NDC.Push("my context message"))
    {
        ... all log calls will have 'my context message' included ...

    } // at the end of the using block the message is automatically removed

#### Requirements

Namespace: log4net

Assembly: log4net (in log4net.dll)

#### See Also

NDC Members | log4net Namespace