Skip to content

AspNetTraceIdentifier Layout Renderer

Rolf Kristensen edited this page Jun 10, 2023 · 8 revisions

ASP.NET Trace Identifier

Platforms Supported: All (Supported in ASP.NET Core and ASP.NET)

Introduced in NLog.Web.AspNetCore ver. 4.3.1 and NLog.Web ver. 4.7.1

Configuration Syntax

${aspnet-TraceIdentifier:ignoreActivityId=boolean}

Options:

  • ignoreActivityId: Only ASP.NET Core. Use HttpContext.TraceIdentifier instead of System.Diagnostics.Activity.Current.Id

Notes

Which TraceIdentifier is used?

  • ASP.NET Core 3: by default System.Diagnostics.Activity.Current.Id.
  • ASP.NET Core 1+2: HttpContext.TraceIdentifier
  • ASP.NET: HttpWorkerRequest.RequestTraceIdentifier.
    • Requires IIS ETW feature enabled, see Microsoft docs
    • Alternative could use ${activityid} together with CorrelationManager.ActivityId.

See code

Clone this wiki locally