-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ${aspnet-traceidentifier} (ASP.NET Core only)
- Loading branch information
1 parent
34f0020
commit d0f10ef
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |