-
Notifications
You must be signed in to change notification settings - Fork 327
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
Logging MDC tags no longer work with logback-classic 1.4.x #1234
Comments
Hey @scheleaap 👋 I looked into this and the problem I found is that sometimes the Play instrumentation gets loaded before the logback instrumentation (see image below). When that happens, the Play instrumentation loads the logback classes before they get instrumented and nothing gets copied.
Running your reproducer several times should work every now and then, depending on the order the modules are loaded. You can workaround it with this setting:
I'll be opening a PR with that same change, assuming that's the only thing we need to fix it 🙏 |
Hi @ivantopo, thank you for taking a look. I am getting consistent results when I run the example project. When I add the setting you mentioned I can see that the Logback instrumentation gets loaded before the Play Framework instrumentation, but it does not bring the MDC tag back. I have updated example project accordingly. Does the application log the MDC tag when you run it on your machine? For reference, here's my log output:
|
We were able to get everything to work thanks to your suggestions @ivantopo. To summarize, in the end we had to make two changes:
Thank you for your valuable support @ivantopo! 💯 I believe we can close this issue now. |
Thanks for sharing your results @scheleaap. Have a great day! |
After upgrading logback-classic from 1.2.11 to 1.4.x, tags set in the Kamon context are no longer included in log messages.
(This problem is similar to #1225, but different: #1225 is about upgrading Kamon, this issue is about upgrading logback-classic.)
At our company, we write log messages in JSON format and add information to the messages through the MDC through Kamon.
We use the latest version of Kamon (2.5.12) with logback-classic and logstash-logback-encoder.
Expected behavior
For example, we add the tag
application-startup-marker
to a log message when the application is starting up:For Kamon 2.5.12 + logback-classic 1.2.11, the log message looks as follows:
Actual behavior
However, when we upgrade logback-classic to 1.4.5, the tag suddenly disappears:
Minimal example
I have created a minimal example here: https://github.com/scheleaap/kamon-issue. Run with
sbt run
.If you change the line
to
in
build.sbt
, you will see the tag reappears.Conclusion
TBH, we are not sure if this is a problem in Kamon or logback-classic. Any insights you can provide would be valuable.
And thank you for your great help on #1225!
The text was updated successfully, but these errors were encountered: