We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
⚠️ NLog 5.0 introduces ScopeContext that replaces NDLC + NDC
Nested Diagnostics Context - a thread-local structure that keeps a stack of strings and provides methods to output them in layouts.
Platforms Supported: All
NDC is considered legacy, and instead is recommended to use NDLC that includes support for async Tasks. See also NLog Context
${ndc:bottomFrames=Integer:topFrames=Integer:separator=String}
-1
Integer
string
NestedDiagnosticsContext.Push("entering method X"); ... // log here NestedDiagnosticsContext.Pop(); //leaving methods
Then in the log config:
${ndc}
logs entering method X if logged between push() and pop()
entering method X
push()
pop()
NestedDiagnosticsContext.Push("entering method X1"); NestedDiagnosticsContext.Push("entering method X2"); ... // log here NestedDiagnosticsContext.Pop(); //leaving method X2 NestedDiagnosticsContext.Pop(); //leaving method X1
logs entering method X1 entering method X2
entering method X1 entering method X2