1

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?

TechNerd
  • 910
  • 1
  • 10
  • 19

1 Answers1

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 LogEvents 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