<PackageReference Include="NLog" Version="6.2.0" />

NLog.ScopeContext

public static class ScopeContext
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)
public static void Clear()

Clears all the entire logical context scope, and removes any properties and nested-states

public static object[] GetAllNestedStates()

Retrieves all nested states inside the logical context scope stack

public static IEnumerable<KeyValuePair<string, object>> GetAllProperties()

Retrieves all properties stored within the logical context scopes

public static object PeekNestedState()

Peeks the top value from the logical context scope stack

public static IDisposable PushNestedState<T>(T nestedState)

Pushes new state on the logical context scope stack

public static IDisposable PushNestedState(object nestedState)

Pushes new state on the logical context scope stack

public static IDisposable PushNestedStateProperties(object nestedState, IReadOnlyCollection<KeyValuePair<string, object>> properties)

Pushes new state on the logical context scope stack together with provided properties

public static IDisposable PushProperties(IReadOnlyCollection<KeyValuePair<string, object>> properties)

Updates the logical scope context with provided properties

public static IDisposable PushProperties<TValue>(IReadOnlyCollection<KeyValuePair<string, TValue>> properties)

Updates the logical scope context with provided properties

public static IDisposable PushProperty<TValue>(string key, TValue value)

Updates the logical scope context with provided property

public static IDisposable PushProperty(string key, object value)

Updates the logical scope context with provided property

public static bool TryGetProperty(string key, out object value)

Lookup single property stored within the logical context scopes