Packages

class SparkLogger extends AnyRef

Guidelines for the Structured Logging Framework - Java Logging

Use the org.apache.spark.internal.SparkLoggerFactory to get the logger instance in Java code: Getting Logger Instance: Instead of using org.slf4j.LoggerFactory, use org.apache.spark.internal.SparkLoggerFactory to ensure structured logging.

import org.apache.spark.internal.SparkLogger; import org.apache.spark.internal.SparkLoggerFactory; private static final SparkLogger logger = SparkLoggerFactory.getLogger(JavaUtils.class);

Logging Messages with Variables: When logging messages with variables, wrap all the variables with MDCs and they will be automatically added to the Mapped Diagnostic Context (MDC).

import org.apache.spark.internal.LogKeys; import org.apache.spark.internal.MDC; logger.error("Unable to delete file for partition {}", MDC.of(LogKeys.PARTITION_ID$.MODULE$, i));

Constant String Messages: For logging constant string messages, use the standard logging methods.

logger.error("Failed to abort the writer after failing to write map output.", e);

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:

// To add a custom LogKey, implement LogKey public static class CUSTOM_LOG_KEY implements LogKey { } import org.apache.spark.internal.MDC; logger.error("Unable to delete key {} for cache", MDC.of(CUSTOM_LOG_KEY, "key"));

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. SparkLogger
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
  6. def debug(msg: String, throwable: Throwable): Unit
  7. def debug(format: String, arguments: <repeated...>[AnyRef]): Unit
  8. def debug(format: String, arg1: AnyRef, arg2: AnyRef): Unit
  9. def debug(format: String, arg: AnyRef): Unit
  10. def debug(msg: String): Unit
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  13. def error(msg: String, throwable: Throwable, mdcs: <repeated...>[MDC]): Unit
  14. def error(msg: String, mdcs: <repeated...>[MDC]): Unit
  15. def error(msg: String, throwable: Throwable): Unit
  16. def error(msg: String): Unit
  17. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  18. def getSlf4jLogger(): Logger
  19. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  20. def info(msg: String, throwable: Throwable, mdcs: <repeated...>[MDC]): Unit
  21. def info(msg: String, mdcs: <repeated...>[MDC]): Unit
  22. def info(msg: String, throwable: Throwable): Unit
  23. def info(msg: String): Unit
  24. def isDebugEnabled(): Boolean
  25. def isErrorEnabled(): Boolean
  26. def isInfoEnabled(): Boolean
  27. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  28. def isTraceEnabled(): Boolean
  29. def isWarnEnabled(): Boolean
  30. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  31. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  32. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  33. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  34. def toString(): String
    Definition Classes
    AnyRef → Any
  35. def trace(msg: String, throwable: Throwable): Unit
  36. def trace(format: String, arguments: <repeated...>[AnyRef]): Unit
  37. def trace(format: String, arg1: AnyRef, arg2: AnyRef): Unit
  38. def trace(format: String, arg: AnyRef): Unit
  39. def trace(msg: String): Unit
  40. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  41. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  42. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  43. def warn(msg: String, throwable: Throwable, mdcs: <repeated...>[MDC]): Unit
  44. def warn(msg: String, mdcs: <repeated...>[MDC]): Unit
  45. def warn(msg: String, throwable: Throwable): Unit
  46. def warn(msg: String): Unit

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from AnyRef

Inherited from Any

Ungrouped