Closed NxSoftware closed 4 years ago
Having a bit more of a look it seems that the RequestId
in the logged scope is retrieved from the HttpContext.TraceIdentifier
property, not sure where the logged TraceId
value comes from.
Regardless, neither value is what was set by the CorrelationId middleware.
The TraceId set in the logging scope above is coming fro the current Activity.
There are quite a lot of considerations around messing with the Activity directly and I currently feel that adjusting that should be a decision in user code. I may revisit that but right now I'm unconvinced. Activities support the concept of correlation of requests and logs and provide a richer, standards-compliant approach. I feel that CorrelationID and Activity should remain distinct. Correlation ID is a simpler library which can be used in place of or alongside Activities.
Same issue here. The "TraceId" I see in my log output is unchanged despite options.UpdateTraceIdentifier = true
. If you AddToLoggingScope = true
it shows up in the logs. Hope this helps someone.
Unless I'm misunderstanding what behaviour this library is intending to provide it would appear that the
TraceId
in the console log scope (enabled using"IncludeScopes": true
inappsettings.json
) doesn't get set to the generated Correlation ID.This is the output from the current
master
branch sample app with the following options provided toAddDefaultCorrelationId
:Trace Id being
1145a7a6-4829067df8c95821
and Correlation Id beingdd6a85fb-1d24-4450-828b-ac5357ac6d57