Playing with log4net, I have seen the possibility to use a per-thread stack of context labels called the NDC.
The labels pushed on this stack are displayed in a Pat
NDC.Push
has been deprecated. The preferred way now (ThreadContext.Stacks["NDC"]
) is this:
var disposable = ThreadContext.Stacks["NDC"].Push("context");
try
{
Log.Info("begin"); // optional, but nice
...
}
finally
{
Log.Info("end"); // optional, but nice
disposable.Dispose();
}
Remember to check your conversion pattern so that it includes %property{NDC}
: