stevejgordon / CorrelationId

An ASP.NET Core middleware component which synchronises a correlation ID for cross API request logging.
MIT License
558 stars 106 forks source link

CorrelationIdMiddleware Logging Question #110

Open mwasson74 opened 2 years ago

mwasson74 commented 2 years ago

Hello,

I've am using your NuGet package and had a question regarding your logging. In CorrelationIdMiddleware Line 147 I am seeing null as the generated CorrelationId in my logs: image

I cloned your repo and had my project reference the clone's dlls instead of the NuGet package and added my own logging line to see if CorrelationId was really null there and it is not.

I realize it's a delegate returned from LoggerMessage.Define() but I don't understand why it prints null in the logs there instead of the actual CorrelationId.

Thanks in advance for helping me understand!!

mwasson74 commented 2 years ago

I noticed something new this morning. When I shutoff/comment-out my Serilog Enricher (screen shot), the CorrelationId logging prints the generated CorrelationId as expected (another screen shot).

Enricher code that can return null: image

Logging with the Enricher shutoff: image