ActivityEnricher uses a cached in Activity LogEventProperty regardless of the current SpanLogEventPropertiesNames, resulting in unnecessary properties in LogEvent and missing desired properties.
The behavior is reproduced on .NET 5.0 and later versions.
Steps to reproduce
Create a project that uses .NET 5.0 or later.
Add two SerilogLoggerProviders writing to two different Loggers, enriched with .Enrich.WithSpan with different SpanLogEventPropertiesNames parameters to the same ILoggerFactory.
Create Logger with the above ILoggerFactory
Start new Activity.
Log something in a scope of the activity above.
Expected behaviour
Expected behavior:
Each Logger receives LogEvents containing properties that have keys according to a corresponding SpanLogEventPropertiesNames.
Actual behavior:
Each Logger receives LogEvents containing properties that have keys set in SpanLogEventPropertiesNames passed to the first SerilogLoggerProvider.
Describe the bug
ActivityEnricher uses a cached in Activity LogEventProperty regardless of the current SpanLogEventPropertiesNames, resulting in unnecessary properties in LogEvent and missing desired properties. The behavior is reproduced on .NET 5.0 and later versions.
Steps to reproduce
.Enrich.WithSpan
with different SpanLogEventPropertiesNames parameters to the same ILoggerFactory.Expected behaviour
Expected behavior: Each Logger receives LogEvents containing properties that have keys according to a corresponding SpanLogEventPropertiesNames.
Actual behavior: Each Logger receives LogEvents containing properties that have keys set in SpanLogEventPropertiesNames passed to the first SerilogLoggerProvider.