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

NLog.Targets.TargetWithContext

Represents target that supports context capture of ScopeContext Properties + Nested-states

Gets the array of custom attributes to be passed into the logevent context

public ISet<string> ExcludeProperties { get; set; }

List of property names to exclude when IncludeEventProperties is true

public bool IncludeCallSite { get; set; }

Gets or sets a value indicating whether to include call site (class and method name) in the LogEventInfo

public bool IncludeCallSiteStackTrace { get; set; }

Gets or sets a value indicating whether to include source info (file name and line number) in the LogEventInfo

public bool IncludeEventProperties { get; set; }

Gets or sets whether to include the contents of the Properties dictionary.

public bool IncludeGdc { get; set; }

Gets or sets a value indicating whether to include contents of the GlobalDiagnosticsContext dictionary

public bool IncludeMdc { get; set; }

Obsolete and replaced by IncludeScopeProperties with NLog v5. Gets or sets whether to include the contents of the MappedDiagnosticsContext-dictionary.

public bool IncludeMdlc { get; set; }

Obsolete and replaced by IncludeScopeProperties with NLog v5. Gets or sets whether to include the contents of the MappedDiagnosticsLogicalContext-properties.

public bool IncludeNdc { get; set; }

Obsolete and replaced by IncludeScopeNested with NLog v5. Gets or sets whether to include the contents of the NestedDiagnosticsContext-stack.

public bool IncludeNdlc { get; set; }

Obsolete and replaced by IncludeScopeNested with NLog v5. Gets or sets whether to include the contents of the NestedDiagnosticsLogicalContext-stack.

public bool IncludeScopeNested { get; set; }

Gets or sets whether to include the contents of the ScopeContext nested-state-stack.

public bool IncludeScopeProperties { get; set; }

Gets or sets whether to include the contents of the ScopeContext properties-dictionary.

protected TargetWithContext()

Constructor

protected virtual IDictionary<string, object> CaptureContextGdc(LogEventInfo logEvent, IDictionary<string, object> contextProperties)

Takes snapshot of GlobalDiagnosticsContext for the LogEventInfo

protected virtual IList<object> CaptureScopeContextNested(LogEventInfo logEvent)

Takes snapshot of nested states from ScopeContext for the LogEventInfo

protected virtual IDictionary<string, object> CaptureScopeContextProperties(LogEventInfo logEvent, IDictionary<string, object> contextProperties)

Takes snapshot of ScopeContext dictionary for the LogEventInfo

protected virtual string GenerateUniqueItemName(LogEventInfo logEvent, string itemName, object itemValue, IDictionary<string, object> combinedProperties)

Generates a new unique name, when duplicate names are detected

protected IDictionary<string, object> GetAllProperties(LogEventInfo logEvent)

Creates combined dictionary of all configured properties for logEvent

protected IDictionary<string, object> GetAllProperties(LogEventInfo logEvent, IDictionary<string, object> combinedProperties)

Creates combined dictionary of all configured properties for logEvent

protected IDictionary<string, object> GetContextMdlc(LogEventInfo logEvent)

Returns the captured snapshot of MappedDiagnosticsLogicalContext for the LogEventInfo

protected IList<object> GetContextNdlc(LogEventInfo logEvent)

Returns the captured snapshot of NestedDiagnosticsLogicalContext for the LogEventInfo

protected IDictionary<string, object> GetContextProperties(LogEventInfo logEvent)

Checks if any context properties, and if any returns them as a single dictionary

protected IDictionary<string, object> GetContextProperties(LogEventInfo logEvent, IDictionary<string, object> combinedProperties)

Checks if any context properties, and if any returns them as a single dictionary

protected IList<object> GetScopeContextNested(LogEventInfo logEvent)

Returns the captured snapshot of nested states from ScopeContext for the LogEventInfo

protected IDictionary<string, object> GetScopeContextProperties(LogEventInfo logEvent)

Returns the captured snapshot of ScopeContext dictionary for the LogEventInfo

protected virtual bool SerializeItemValue(LogEventInfo logEvent, string name, object value, out object serializedValue)

Take snapshot of a single object value

protected virtual bool SerializeScopeContextNestedState(LogEventInfo logEvent, object value, out object serializedValue)

Take snapshot of a single object value from ScopeContext nested states

protected virtual bool SerializeScopeContextProperty(LogEventInfo logEvent, string name, object value, out object serializedValue)

Take snapshot of a single object value from ScopeContext dictionary

protected bool ShouldIncludeProperties(LogEventInfo logEvent)

Check if logevent has properties (or context properties)