-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Steeltoe 3.2.0 breaks Serilog structured logging #895
Comments
@christianerbsmehl I took a look at this. In 3.2 we added the feature to add support for IDynamicMessageProcessor which adds things like span and traceID to add context to logs. Unfortunately, I think this broke compatibility with the structured logging. I am looking for a work around. |
@christianerbsmehl the short answer to this is that the IDynamicMessageProcessor adds context to logs by calling the formatter ahead of time and then appends data. Whereas the serilog implementation uses the values in TState of Log to render the the structured logs. So this is obviously a problem - we can pick one or the other - either have structured logs preserved or lose the ability add trace context. I am guessing this cannot be fixed in Steeltoe code base. |
The IDynamicMessageProcessor is a Steeltoe thing, isn't it? Can you give me some context why this was introduced and what's the use case? From the linked issue (#835) I understood that TraceId and SpanId should be included in the console output. |
Describe the bug
After upgrading
Steeltoe.Extensions.Logging.DynamicSerilogBase
from version3.1.3
to3.2.0
, structured logging with Serilog is broken, which means that message properties are not extracted from the log message. Additionally, the console output is not colored anymore.I created a sample project to demonstrate the issue: https://github.com/christianerbsmehl/steeltoe-serilog
To narrow down the problem, I configured the Serilog file sink with the compact JSON formatter. I found out, that with DynamicSerilogBase 3.2.0 the message template is missing the curly braces around the message properties:
Using DynamicSerilogBase 3.1.3, output looks like this:
Note the curly braces around
value
in the message template and the extracted"value":"value"
property.Steps to reproduce
Steps to reproduce the behavior:
Steeltoe.Extensions.Logging.DynamicSerilogBase 3.2.0
andSerilog.AspNetCore 6.0.1
In
Program.cs
:In
appSettings.json
:For details please refer to the sample project I provided above.
Expected behavior
Message properties should be extracted again and the message template should have curly braces around properties.
Environment
The text was updated successfully, but these errors were encountered: