mthamil / AspNetCore.Serilog.RequestLoggingMiddleware

Middleware for ASP.NET Core that uses Serilog to log requests.
Apache License 2.0
8 stars 1 forks source link

Logging Enriched Properties #6

Open clintcarter1999 opened 3 years ago

clintcarter1999 commented 3 years ago

I added a LogContext property, CorrelationId, which am able to log using the output template:

"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} | {Level:u3} | {CorrelationId} | {Message:lj}{NewLine}{Exception}"

Most of the log lines show the CorrelationId. e.

2021-05-20 10:18:19.971 | INF | CID: 12345C12 | Executed endpoint ... 2021-05-20 10:18:19.975 | INF | CID: 12345C12 | HTTP GET /api/v1/model/search?...responded 200 in 2396.5086 ms 2021-05-20 10:18:19.977 | DBG | CID: 12345C12 | [Response]: 200: {...}

The summary line from this middleware does not log the CorrelationId

2021-05-20 10:18:19.981 | INF | | Request finished in 2411.9684ms 200 application/json; charset=utf-8

Is there a way for this Middleware to log this?

mthamil commented 3 years ago

There is now official Serilog request logging middleware: https://github.com/serilog/serilog-aspnetcore#request-logging Does it provide what you need? If not, I can look into this more.