Skip to content

Commit

Permalink
Faster logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Wright authored and Lee Wright committed Aug 6, 2024
1 parent a49bd46 commit 49791dc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion backend/common/Logging/CorrelationIdMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@ public async Task InvokeAsync(HttpContext context)
context.Response.Headers.Append(CorrelationIdHeader, correlationId);
using (LogContext.PushProperty(CorrelationIdHeader, correlationId))
{
logger.LogTrace($"CorrelationId: {correlationId} {context.Request.GetEncodedUrl}");
logger.LogCorrelationRequest(correlationId, context.Request.GetDisplayUrl());
await next(context);
}
}
}

public static partial class CommonLoggingExtensions
{
//--------------------------------------------------------------------------------
// Http Logging
//--------------------------------------------------------------------------------
[LoggerMessage(1, LogLevel.Trace, "CorrelationId: {correlationId} {requestUrl}")]
public static partial void LogCorrelationRequest(this ILogger logger, string correlationId, string requestUrl);
}

0 comments on commit 49791dc

Please sign in to comment.