LuciferYang commented on code in PR #48057:
URL: https://github.com/apache/spark/pull/48057#discussion_r1752095345


##########
common/utils/src/test/resources/log4j2.component.properties:
##########
@@ -0,0 +1 @@
+log4j2.garbagefree.threadContextMap = true

Review Comment:
   
https://github.com/apache/spark/blob/7355864e2cf8329188e69365415ab0bd718d0c1a/common/utils/src/test/scala/org/apache/spark/util/StructuredLoggingSuite.scala#L468C3-L478
   
   ```scala
     test("setting to MDC gets logged") {
       val mdcPattern = s""""${LogKeys.DATA.name}":"some-data""""
   
       org.slf4j.MDC.put(LogKeys.DATA.name, "some-data")
       val logOutputWithMDCSet = captureLogOutput(() => logInfo(msgWithMDC))
       assert(mdcPattern.r.findFirstIn(logOutputWithMDCSet).isDefined)
   
       org.slf4j.MDC.remove(LogKeys.DATA.name)
       val logOutputWithoutMDCSet = captureLogOutput(() => logInfo(msgWithMDC))
       assert(mdcPattern.r.findFirstIn(logOutputWithoutMDCSet).isEmpty)
     }
   ```
   
   There is a significant refactoring in the `ThreadContextMap` 
component(https://github.com/apache/logging-log4j2/pull/2330), resulting in the 
loss of key-value pairs injected via `org.slf4j.MDC` during the generation of 
`LogEvent` objects when using `DefaultThreadContextMap`. As a workaround, it is 
necessary to configure and employ `GarbageFreeSortedArrayThreadContextMap`. I 
am puzzled by this situation. Since `org.slf4j.MDC` is a behavior specific to 
SLF4J, and this does not appear to be an incompatible change for Log4j, let's 
currently halt this upgrade and wait to see if the new version of SLF4J can 
address this issue.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to