-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
${aspnet-TraceIdentifier:ignoreActivityId=boolean}
-
ignoreActivityId: Only ASP.NET Core. Use
HttpContext.TraceIdentifier
instead ofSystem.Diagnostics.Activity.Current.Id
- 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
- Troubleshooting Guide - See available NLog Targets and Layouts: https://nlog-project.org/config
- Getting started
- How to use structured logging
- Troubleshooting
- FAQ
-
All targets, layouts and layout renderers
Popular: - Using NLog with NLog.config
- Using NLog with appsettings.json