NLog by Jarek Kowalski,Kim Christensen,Julian Verdurmen

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

 TargetWithContext

Represents target that supports context capture using MDLC, MDC, NDLC and NDC

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

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; }

public bool IncludeGdc { get; set; }

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

public bool IncludeMdc { get; set; }

public bool IncludeMdlc { get; set; }

public bool IncludeNdc { get; set; }

public bool IncludeNdlc { get; set; }

protected TargetWithContext()

Constructor

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

Takes snapshot of GlobalDiagnosticsContext for the LogEventInfo

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

Takes snapshot of MappedDiagnosticsContext for the LogEventInfo

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

Takes snapshot of MappedDiagnosticsLogicalContext for the LogEventInfo

protected virtual IList<object> CaptureContextNdc(LogEventInfo logEvent)

Takes snapshot of NestedDiagnosticsContext for the LogEventInfo

protected virtual IList<object> CaptureContextNdlc(LogEventInfo logEvent)

Takes snapshot of NestedDiagnosticsLogicalContext for the LogEventInfo

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

Creates combined dictionary of all configured properties for logEvent

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

Returns the captured snapshot of MappedDiagnosticsContext for the LogEventInfo

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

Returns the captured snapshot of MappedDiagnosticsLogicalContext for the LogEventInfo

protected IList<object> GetContextNdc(LogEventInfo logEvent)

Returns the captured snapshot of NestedDiagnosticsContext 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 virtual bool SerializeItemValue(LogEventInfo logEvent, string name, object value, out object serializedValue)

Take snapshot of a single object value

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

Take snapshot of a single object value from MappedDiagnosticsContext

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

Take snapshot of a single object value from MappedDiagnosticsLogicalContext

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

Take snapshot of a single object value from NestedDiagnosticsContext

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

Take snapshot of a single object value from NestedDiagnosticsLogicalContext

protected bool ShouldIncludeProperties(LogEventInfo logEvent)

Check if logevent has properties (or context properties)