mridulm commented on code in PR #46634:
URL: https://github.com/apache/spark/pull/46634#discussion_r1606345907
##########
common/utils/src/main/scala/org/apache/spark/internal/README.md:
##########
@@ -45,3 +45,29 @@ logger.error("Failed to abort the writer after failing to
write map output.", e)
## Exceptions
To ensure logs are compatible with Spark SQL and log analysis tools, avoid
`Exception.printStackTrace()`. Use `logError`, `logWarning`, and `logInfo`
methods from the `Logging` trait to log exceptions, maintaining structured and
parsable logs.
+
+## External third-party ecosystem access
+
+* If you want to output logs in `scala code` through the structured log
framework, you can define `custom LogKey` and use it in `scala` code as follows:
+
+```scala
+// External third-party ecosystem `custom LogKey` must be `extends LogKey`
+case object CUSTOM_LOG_KEY extends LogKey
+```
+```scala
+import org.apache.spark.internal.MDC;
+
+logInfo(log"${MDC(CUSTOM_LOG_KEY, "key")}")
+```
+
+* If you want to output logs in `java code` through the structured log
framework, you can define `custom LogKey` and use it in `java` code as follows:
+
+```java
+// External third-party ecosystem `custom LogKey` must be `implements LogKey`
+public static class CUSTOM_LOG_KEY implements LogKey { }
+```
+```java
+import org.apache.spark.internal.MDC;
+
+logger.error("Unable to delete key {} for cache", MDC.of(CUSTOM_LOG_KEY,
"key"));
+```
Review Comment:
I am not sure I follow the question.
Is spark Logging being used today by third party ? Yes.
Do we support it ? No.
Do we disallow it ? Not really - power users put all sorts of things in
org.apache.spark namespace and access internals, but we don't support that.
We are able to make these changes for structured logging, potentially
breaking some usecases out there (even if we are making efforts to minimize
impact) because this is an internal api.
--
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]