You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/12/26 20:06:10 UTC

[GitHub] [spark] viirya commented on a change in pull request #35026: [SPARK-37746][CORE] log4j2-defaults.properties is not working since log4j 2 is always initialized by default

viirya commented on a change in pull request #35026:
URL: https://github.com/apache/spark/pull/35026#discussion_r775280208



##########
File path: core/src/main/scala/org/apache/spark/internal/Logging.scala
##########
@@ -126,11 +126,14 @@ trait Logging {
 
   private def initializeLogging(isInterpreter: Boolean, silent: Boolean): Unit = {
     if (Logging.isLog4j2()) {
-      // If Log4j is used but is not initialized, load a default properties file
-      val log4j2Initialized = !LogManager.getRootLogger
-        .asInstanceOf[org.apache.logging.log4j.core.Logger].getAppenders.isEmpty
+      val rootLogger = LogManager.getRootLogger.asInstanceOf[org.apache.logging.log4j.core.Logger]
+      // If Log4j 2 is used but is initialized by default configuration,
+      // load a default properties file
+      // (see org.apache.logging.log4j.core.config.DefaultConfiguration)
+      val needToInitializeLog4j2 = rootLogger.getAppenders.isEmpty ||
+        (rootLogger.getAppenders.size() == 1 && rootLogger.getLevel == Level.ERROR)

Review comment:
       https://github.com/apache/logging-log4j2/blob/5edf43758f104affad9842753e66be173fc4d68a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java#L708




-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org