ekmsystems / serilog-enrichers-correlation-id

Enrich logs with a unique ID so you can track logs for specific requests.
MIT License
93 stars 37 forks source link

Correlation Id is not getting printed #94

Open DevOnRun opened 1 year ago

DevOnRun commented 1 year ago

.Net version: 6.0

Dependency packages Serilog version: 2.10.0 Serilog.AspNetCore version: 6.1.0

Sample log printed: {"@t":"2023-02-02T13:05:26.3628967Z","@m":"Request finished HTTP/1.1 GET http://localhost:5099/api/v1/LocationWeather - - - 404 - appliction/json 1516.1679ms","@i":"791a596a","ElapsedMilliseconds":1516.1679,"StatusCode":404,"ContentType":"appliction/json","ContentLength":null,"Protocol":"HTTP/1.1","Method":"GET","Scheme":"http","Host":"localhost:5099","PathBase":"","Path":"/api/v1/LocationWeather","QueryString":"","HostingRequestFinishedLog":"Request finished HTTP/1.1 GET http://localhost:5099/api/v1/LocationWeather - - - 404 - appliction/json 1516.1679ms","EventId":{"Id":2},"SourceContext":"Microsoft.AspNetCore.Hosting.Diagnostics","RequestId":"0HMO53O3VJI4V:00000005","RequestPath":"/api/v1/LocationWeather","ConnectionId":"0HMO53O3VJI4V","MachineName":"DESKTOP-xxxxx","ServiceName":"Test.LocationWeatherService","ServiceVersion":"1.0.0.0"}

NotIlya4 commented 1 year ago

You need this to make it work: builder.Services.AddHttpContextAccessor();