aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Wendell <pwendell@gmail.com>2014-02-08 23:35:31 -0800
committerReynold Xin <rxin@apache.org>2014-02-08 23:35:31 -0800
commitb6d40b782327188a25ded5b22790552121e5271f (patch)
treede411ec59c3081a4a4478357cde4188d32ebeb92
parentf892da8716d614467fddcc3a1b2b589979414219 (diff)
downloadspark-b6d40b782327188a25ded5b22790552121e5271f.tar.gz
spark-b6d40b782327188a25ded5b22790552121e5271f.tar.bz2
spark-b6d40b782327188a25ded5b22790552121e5271f.zip
Merge pull request #560 from pwendell/logging. Closes #560.
[WIP] SPARK-1067: Default log4j initialization causes errors for those not using log4j To fix this - we add a check when initializing log4j. Author: Patrick Wendell <pwendell@gmail.com> == Merge branch commits == commit ffdce513877f64b6eed6d36138c3e0003d392889 Author: Patrick Wendell <pwendell@gmail.com> Date: Fri Feb 7 15:22:29 2014 -0800 Logging fix
-rw-r--r--core/src/main/scala/org/apache/spark/Logging.scala7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/src/main/scala/org/apache/spark/Logging.scala b/core/src/main/scala/org/apache/spark/Logging.scala
index b749e5414d..7423082e34 100644
--- a/core/src/main/scala/org/apache/spark/Logging.scala
+++ b/core/src/main/scala/org/apache/spark/Logging.scala
@@ -19,6 +19,7 @@ package org.apache.spark
import org.apache.log4j.{LogManager, PropertyConfigurator}
import org.slf4j.{Logger, LoggerFactory}
+import org.slf4j.impl.StaticLoggerBinder
/**
* Utility trait for classes that want to log data. Creates a SLF4J logger for the class and allows
@@ -101,9 +102,11 @@ trait Logging {
}
private def initializeLogging() {
- // If Log4j doesn't seem initialized, load a default properties file
+ // If Log4j is being used, but is not initialized, load a default properties file
+ val binder = StaticLoggerBinder.getSingleton
+ val usingLog4j = binder.getLoggerFactoryClassStr.endsWith("Log4jLoggerFactory")
val log4jInitialized = LogManager.getRootLogger.getAllAppenders.hasMoreElements
- if (!log4jInitialized) {
+ if (!log4jInitialized && usingLog4j) {
val defaultLogProps = "org/apache/spark/log4j-defaults.properties"
val classLoader = this.getClass.getClassLoader
Option(classLoader.getResource(defaultLogProps)) match {