1. SLF4J (Simple Logging Facade for Java) Manual: The official documentation for SLF4J
which is the standard logging facade used by Apache Spark and other Hadoop ecosystem components
explicitly recommends and documents this parameterized style. The FAQ explains its performance advantage.
Source: SLF4J Manual
FAQ section.
Reference: In the question "What is the fastest way of logging?"
the manual states: "the SLF4J API supports parameterized logging which can significantly boost logging performance." It provides the example: logger.debug("Entry number: {} is {}"
i
entry);. This directly matches the pattern in option A.
2. Apache Spark Documentation: Spark's official documentation confirms its use of the SLF4J API for logging
making SLF4J's best practices directly applicable.
Source: Apache Spark 3.5.1 Documentation
"Configuration" page
section on "Configuring Logging".
Reference: The documentation states
"Spark uses log4j for logging. You can configure it by adding a log4j2.properties file...". Log4j 2 is a primary implementation of the SLF4J API and heavily promotes the use of parameterized messages for performance
as shown in option A.
3. Log4j 2 Architecture Documentation: As a backend for SLF4J in the Cloudera/Spark ecosystem
the Log4j 2 documentation details the benefits of parameterized messages.
Source: Apache Log4j 2 Documentation
"Architecture" section.
Reference: The documentation emphasizes that "parameterized messages... allow the logging system to only format the message if it is going to be logged
" which avoids the cost of parameter construction for disabled log statements. This principle directly supports option A over option C.