I am using Serilog for logging in my Web API project, with the web classic nuget package installed I am simply able to log a unique GUID value per request. From my Logger is there anyway to access that value? I know that any time I am writing to a file it should be written to it, but I want to read it from the logger context, is there anyway of doing this?
Asked
Active
Viewed 1,399 times
1 Answers
1
There's no method that is supported/straightforward (there may be some hacks, you'd need to read the source for the SerilogWeb.Classic package to figure this out however).
If you add an ILogEventEnricher
to the pipeline, it can inspect LogEvent
s emitted during the request and retrieve the HttpRequestId
at that point - though I'm unsure if this is useful in your scenario.

Nicholas Blumhardt
- 30,271
- 4
- 90
- 101