24 lines
565 B
C#
24 lines
565 B
C#
using Serilog.Context;
|
|
|
|
namespace Crm.Core.WebApi.Middlewares
|
|
{
|
|
public class RequestLogContextMiddleware
|
|
{
|
|
private readonly RequestDelegate _next;
|
|
|
|
public RequestLogContextMiddleware(RequestDelegate next)
|
|
{
|
|
_next = next;
|
|
}
|
|
|
|
public Task Invoke(HttpContext context)
|
|
{
|
|
var correlationId = context.GetCorrelationId();
|
|
using (LogContext.PushProperty("CorrelationId", correlationId))
|
|
{
|
|
return _next.Invoke(context);
|
|
}
|
|
}
|
|
}
|
|
}
|