Skip to content

Commit

Permalink
Add ${aspnet-traceidentifier} (ASP.NET Core only)
Browse files Browse the repository at this point in the history
  • Loading branch information
304NotModified committed Feb 10, 2017
1 parent 34f0020 commit d0f10ef
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions NLog.Web.AspNetCore/LayoutRenderers/Class.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Print the TraceIdentifier
/// </summary>
/// <remarks>.NET Core Only</remarks>
[LayoutRenderer("aspnet-traceidentifier")]
public class AspNetTraceIdentifierLayoutRenderer : AspNetLayoutRendererBase
{
/// <inheritdoc />
protected override void DoAppend(StringBuilder builder, LogEventInfo logEvent)
{
var context = HttpContextAccessor.HttpContext;

builder.Append(context.TraceIdentifier);
}
}
}

0 comments on commit d0f10ef

Please sign in to comment.