Click or drag to resize

ScopeContext Class

ScopeContext stores state in the async thread execution context. All LogEvents created within a scope can include the scope state in the target output. The logical context scope supports both scope-properties and scope-nested-state-stack (Similar to log4j2 ThreadContext)
Inheritance Hierarchy
SystemObject
  NLogScopeContext

Namespace:  NLog
Assembly:  NLog (in NLog.dll) Version: 5.3.4+73d83d3161d31288ca5c554cc50d27b6bed5f28b
Syntax
public static class ScopeContext

The ScopeContext type exposes the following members.

Methods
  NameDescription
Public methodStatic memberClear
Clears all the entire logical context scope, and removes any properties and nested-states
Public methodStatic memberGetAllNestedStates
Retrieves all nested states inside the logical context scope stack
Public methodStatic memberGetAllProperties
Retrieves all properties stored within the logical context scopes
Public methodStatic memberPeekNestedState
Peeks the top value from the logical context scope stack
Public methodStatic memberPushNestedState(Object)
Pushes new state on the logical context scope stack
Public methodStatic memberPushNestedStateT(T)
Pushes new state on the logical context scope stack
Public methodStatic memberPushNestedStateProperties
Pushes new state on the logical context scope stack together with provided properties
Public methodStatic memberPushProperties(IReadOnlyCollectionKeyValuePairString, Object)
Updates the logical scope context with provided properties
Public methodStatic memberPushPropertiesTValue(IReadOnlyCollectionKeyValuePairString, TValue)
Updates the logical scope context with provided properties
Public methodStatic memberPushProperty(String, Object)
Updates the logical scope context with provided property
Public methodStatic memberPushPropertyTValue(String, TValue)
Updates the logical scope context with provided property
Public methodStatic memberTryGetProperty
Lookup single property stored within the logical context scopes
Top
Remarks
MappedDiagnosticsLogicalContext (MDLC), MappedDiagnosticsContext (MDC), NestedDiagnosticsLogicalContext (NDLC) and NestedDiagnosticsContext (NDC) have been deprecated and replaced by ScopeContext. .NetCore (and .Net46) uses AsyncLocal for handling the thread execution context. Older .NetFramework uses System.Runtime.Remoting.CallContext
See Also