File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
core/src/main/scala/org/apache/spark Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package org.apache.spark
1919
2020import org .apache .log4j .{LogManager , PropertyConfigurator }
2121import org .slf4j .{Logger , LoggerFactory }
22+ import org .slf4j .impl .StaticLoggerBinder
2223
2324/**
2425 * Utility trait for classes that want to log data. Creates a SLF4J logger for the class and allows
@@ -101,9 +102,11 @@ trait Logging {
101102 }
102103
103104 private def initializeLogging () {
104- // If Log4j doesn't seem initialized, load a default properties file
105+ // If Log4j is being used, but is not initialized, load a default properties file
106+ val binder = StaticLoggerBinder .getSingleton
107+ val usingLog4j = binder.getLoggerFactoryClassStr.endsWith(" Log4jLoggerFactory" )
105108 val log4jInitialized = LogManager .getRootLogger.getAllAppenders.hasMoreElements
106- if (! log4jInitialized) {
109+ if (! log4jInitialized && usingLog4j ) {
107110 val defaultLogProps = " org/apache/spark/log4j-defaults.properties"
108111 val classLoader = this .getClass.getClassLoader
109112 Option (classLoader.getResource(defaultLogProps)) match {
You can’t perform that action at this time.
0 commit comments