-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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 framework uses MDC adapter provided by SubstituteServiceProvider even after initialization of CustomServiceProvider #450
Comments
Hi @ceki, |
@ceki Thanks for looking into the issue. |
MDC class from the static initializer to the LoggerFactory.bind method. In case MDC methods are called before LoggerFactory, the various methods in MDC have been modified to go through the getMDCAdapter method which checks for this rare case. #450 Signed-off-by: Ceki Gulcu <[email protected]>
@OmShinde1513 This issue is solved in commit 9349d64 |
@ceki Thanks a lot for the quick turnaround. When will the next release be available which will contain this fix? |
Hi @ceki Thanks for looking into issue, |
@ceki The fix is not working for use. I think this might be very specific to our usage of logback and sl4j. App.txt Thanks for looking into this. |
@viphadke Thank you for the helpful clarification. |
@ceki Do you have any ETA on a possible solution ? |
MDC class from the static initializer to the LoggerFactory.bind method. In case MDC methods are called before LoggerFactory, the various methods in MDC have been modified to go through the getMDCAdapter method which checks for this rare case. #450 Signed-off-by: Ceki Gulcu <[email protected]>
Logback version 1.5.17 has been released a short time ago. See also https://logback.qos.ch/news.html#1.5.17 |
### What changes were proposed in this pull request? This pr aims to upgrade slf4j from 2.0.16 to 2.0.17. ### Why are the changes needed? The new version brings some bug fixes, like: - As reported in qos-ch/slf4j#450, in some rare cases where MDC could be initialized before LoggerFactory. Thus, MDC would be stuck using the wrong MDCAdapter instance. To fix this issue LoggerFactory and MDC have been modified. Implementations of SLF4JServiceProvider are encouraged to initialize their mdcAdapter and markerFactory fields as early as possible, preferably at construction time. Note that these changes are transparent to existing logging backends which will continue to work as is. - Fixed incorrect interpretation of Level.OFF and Level.ALL in SLF4JPlatformLogger by mapping Level.OFF as Level.ERROR and Level.ALL as Level.TRACE. This issue was reported in qos-ch/slf4j#430 by Peter Halicky. The full release notes as follows: - https://github.com/qos-ch/slf4j/releases/tag/v_2.0.17 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Pass GitHub Actions ### Was this patch authored or co-authored using generative AI tooling? No Closes #50115 from LuciferYang/slf4j-2.0.17. Lead-authored-by: yangjie01 <[email protected]> Co-authored-by: YangJie <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
### What changes were proposed in this pull request? This pr aims to upgrade slf4j from 2.0.16 to 2.0.17. ### Why are the changes needed? The new version brings some bug fixes, like: - As reported in qos-ch/slf4j#450, in some rare cases where MDC could be initialized before LoggerFactory. Thus, MDC would be stuck using the wrong MDCAdapter instance. To fix this issue LoggerFactory and MDC have been modified. Implementations of SLF4JServiceProvider are encouraged to initialize their mdcAdapter and markerFactory fields as early as possible, preferably at construction time. Note that these changes are transparent to existing logging backends which will continue to work as is. - Fixed incorrect interpretation of Level.OFF and Level.ALL in SLF4JPlatformLogger by mapping Level.OFF as Level.ERROR and Level.ALL as Level.TRACE. This issue was reported in qos-ch/slf4j#430 by Peter Halicky. The full release notes as follows: - https://github.com/qos-ch/slf4j/releases/tag/v_2.0.17 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Pass GitHub Actions ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#50115 from LuciferYang/slf4j-2.0.17. Lead-authored-by: yangjie01 <[email protected]> Co-authored-by: YangJie <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
### What changes were proposed in this pull request? This pr aims to upgrade slf4j from 2.0.16 to 2.0.17. ### Why are the changes needed? The new version brings some bug fixes, like: - As reported in qos-ch/slf4j#450, in some rare cases where MDC could be initialized before LoggerFactory. Thus, MDC would be stuck using the wrong MDCAdapter instance. To fix this issue LoggerFactory and MDC have been modified. Implementations of SLF4JServiceProvider are encouraged to initialize their mdcAdapter and markerFactory fields as early as possible, preferably at construction time. Note that these changes are transparent to existing logging backends which will continue to work as is. - Fixed incorrect interpretation of Level.OFF and Level.ALL in SLF4JPlatformLogger by mapping Level.OFF as Level.ERROR and Level.ALL as Level.TRACE. This issue was reported in qos-ch/slf4j#430 by Peter Halicky. The full release notes as follows: - https://github.com/qos-ch/slf4j/releases/tag/v_2.0.17 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Pass GitHub Actions ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#50115 from LuciferYang/slf4j-2.0.17. Lead-authored-by: yangjie01 <[email protected]> Co-authored-by: YangJie <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
Hi,
I'm Using logback 1.5.16 logging framework and slf4j 2.0.16,
when LogbackServiceProvider initialization is ongoing, slf4j provides SubstituteServiceProvider,
In static block of MDC class, mdcAdapter is initialized with BasicMDCAdapter provided by SubstituteServiceProvider, and this is not replaced with MDCAdapter provided by LogbackServiceProvider after service providers initialization completed.
Hence MDC key values are placed in this BasicMDCAdapter, But logback appenders get mdcPropertyMap from its own MDCAdapter so this map gets empty as all property values placed in map of BasicMDCAdapter.
ex:
// After custome service initialization completed.
MDC.put(key,value) -> puts this in BasicMDCAdapter provided by SubstituteServiceProvider.
loggerContext.getMDCAdapter() -> this adapter have empty PropertyMap, which is used by logback to set mdc properties to LoggingEvent.
After initialization of CustomServiceProvider MDCAdapter should be replaced with its MDCAdapter.
The text was updated successfully, but these errors were encountered: