From d0f10efb214bd47b94abdc3eb4035ec20f55ab92 Mon Sep 17 00:00:00 2001
From: Julian Verdurmen <304NotModified@users.noreply.github.com>
Date: Fri, 10 Feb 2017 20:04:13 +0100
Subject: [PATCH] Add ${aspnet-traceidentifier} (ASP.NET Core only)
---
NLog.Web.AspNetCore/LayoutRenderers/Class.cs | 25 ++++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 NLog.Web.AspNetCore/LayoutRenderers/Class.cs
diff --git a/NLog.Web.AspNetCore/LayoutRenderers/Class.cs b/NLog.Web.AspNetCore/LayoutRenderers/Class.cs
new file mode 100644
index 00000000..59bb48fc
--- /dev/null
+++ b/NLog.Web.AspNetCore/LayoutRenderers/Class.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using NLog.LayoutRenderers;
+
+namespace NLog.Web.LayoutRenderers
+{
+ ///
+ /// Print the TraceIdentifier
+ ///
+ /// .NET Core Only
+ [LayoutRenderer("aspnet-traceidentifier")]
+ public class AspNetTraceIdentifierLayoutRenderer : AspNetLayoutRendererBase
+ {
+ ///
+ protected override void DoAppend(StringBuilder builder, LogEventInfo logEvent)
+ {
+ var context = HttpContextAccessor.HttpContext;
+
+ builder.Append(context.TraceIdentifier);
+ }
+ }
+}