Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-49216][CORE] Fix to not log message context with explicitly Lo…
…gEntry constructed when Structured Logging conf is off ### What changes were proposed in this pull request? To use structured logging developers usually do ```scala logInfo(log"Lost executor ${MDC(LogKeys.EXECUTOR_ID, "1")}."), ``` When the structured logging conf is off, the context is not logged. However if explicitly constructing the LogEntry and calling the public API, ```scala logInfo( MessageWithContext( "Lost executor 1.", new java.util.HashMap[String, String] { put(LogKeys.EXECUTOR_ID.name, "1") } ) ) ``` the conf does not take effect and even when it is off, the context is still logged. This PR creates a fix for both cases to observe the conf, by toggling in the `withLogContext` function. This PR also adds a extra small test on explicitly setting MDC. ### Why are the changes needed? To keep consistency between APIs. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added new unit tests. ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#47732 from anchovYu/structured-logging-conf. Authored-by: Xinyi Yu <xinyi.yu@databricks.com> Signed-off-by: Gengliang Wang <gengliang@apache.org>
- Loading branch information