anchovYu commented on code in PR #47732:
URL: https://github.com/apache/spark/pull/47732#discussion_r1715714109
##########
common/utils/src/test/scala/org/apache/spark/util/StructuredLoggingSuite.scala:
##########
@@ -438,6 +438,44 @@ class StructuredLoggingSuite extends LoggingSuiteBase {
assert((log"\r" + log"\n" + log"\t" + log"\b").message == "\r\n\t\b")
assert((log"\r${MDC(LogKeys.EXECUTOR_ID, 1)}\n".message == "\r1\n"))
}
+
+ test("disabled structured logging won't log context") {
+ Logging.disableStructuredLogging()
+ val expectedPatternWithoutContext = compactAndToRegexPattern(
+ s"""
+ {
+ "ts": "<timestamp>",
+ "level": "INFO",
+ "msg": "Lost executor 1.",
+ "logger": "$className"
+ }""")
+
+ Seq(
+ () => logInfo(log"Lost executor ${MDC(LogKeys.EXECUTOR_ID, "1")}."),
+ () => logInfo( // blocked when explicitly constructing the
MessageWithContext
+ MessageWithContext(
+ "Lost executor 1.",
+ new java.util.HashMap[String, String] {
put(LogKeys.EXECUTOR_ID.name, "1") }
Review Comment:
The MDC context is set in `withLogContext`, checking the config value there
should meet the semantics of this config. But I can add changes in lines 154 -
156 back to even avoid setting those in the data structure!
--
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]