-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
MDC Properties Not Associated with Log Statements #709
Comments
@naser-ayat As of logback 1.4..8 (commit ca7fbc7 LoggingEvent will fetch MDC data from the MDCAdapter attached to its LoggingContext. Previously, the MDCAdapter instance was located statically through the MDC.MDC.getMDCAdapter() method. You can solve this problem by adding the following line in your code:
See also the previous discussion of this issue at spring-projects/spring-boot#36177 |
@ceki Looking at the
|
Also take note that there will be a null pointer exception in https://github.com/qos-ch/logback/blame/8a746eb0eff709ac036fb4d6ab0719aaffbc0702/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java#L411 if no MDC is set. This unfortunately breaks any upgrade from 1.3.7 to 1.3.8 without making additional changes. |
Starting from version 1.4.8 of Logback, an issue has been observed where MDC properties are no longer associated with log statements when a custom
MDCAdapter
, for instancecom.twitter.inject.logging.FinagleMDCAdapter
, is set in the application.The likely root cause is that, beginning with version 1.4.8, Logback obtains the
MDCAdapter
fromch.qos.logback.classic.LoggerContext
instead of directly getting it from MDC. Consequently, the application ends up using two separate and independent MDCAdapters concurrently.You can find a simplified application created to reproduce this issue in the following repository:
https://github.com/naser-ayat/logback-bug-reproducer
The text was updated successfully, but these errors were encountered: