diff options
author | zsxwing <zsxwing@gmail.com> | 2015-06-10 13:25:59 -0700 |
---|---|---|
committer | Andrew Or <andrew@databricks.com> | 2015-06-10 13:26:33 -0700 |
commit | 80043e9e761c44ce2c3a432dcd1989be573f8bb4 (patch) | |
tree | 0b09bcf970087091c98728f7c17d5de3f7eae9ac /core/src/main/scala/org | |
parent | e90c9d92d9a86e9960c10a5c043f3c02f6c636f9 (diff) | |
download | spark-80043e9e761c44ce2c3a432dcd1989be573f8bb4.tar.gz spark-80043e9e761c44ce2c3a432dcd1989be573f8bb4.tar.bz2 spark-80043e9e761c44ce2c3a432dcd1989be573f8bb4.zip |
[SPARK-7261] [CORE] Change default log level to WARN in the REPL
1. Add `log4j-defaults-repl.properties` that has log level WARN.
2. When logging is initialized, check whether inside the REPL. If so, use `log4j-defaults-repl.properties`.
3. Print the following information if using `log4j-defaults-repl.properties`:
```
Using Spark's repl log4j profile: org/apache/spark/log4j-defaults-repl.properties
To adjust logging level use sc.setLogLevel("INFO")
```
Author: zsxwing <zsxwing@gmail.com>
Closes #6734 from zsxwing/log4j-repl and squashes the following commits:
3835eff [zsxwing] Change default log level to WARN in the REPL
Diffstat (limited to 'core/src/main/scala/org')
-rw-r--r-- | core/src/main/scala/org/apache/spark/Logging.scala | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/core/src/main/scala/org/apache/spark/Logging.scala b/core/src/main/scala/org/apache/spark/Logging.scala index 419d093d55..7fcb7830e7 100644 --- a/core/src/main/scala/org/apache/spark/Logging.scala +++ b/core/src/main/scala/org/apache/spark/Logging.scala @@ -121,13 +121,25 @@ trait Logging { if (usingLog4j12) { val log4j12Initialized = LogManager.getRootLogger.getAllAppenders.hasMoreElements if (!log4j12Initialized) { - val defaultLogProps = "org/apache/spark/log4j-defaults.properties" - Option(Utils.getSparkClassLoader.getResource(defaultLogProps)) match { - case Some(url) => - PropertyConfigurator.configure(url) - System.err.println(s"Using Spark's default log4j profile: $defaultLogProps") - case None => - System.err.println(s"Spark was unable to load $defaultLogProps") + if (Utils.isInInterpreter) { + val replDefaultLogProps = "org/apache/spark/log4j-defaults-repl.properties" + Option(Utils.getSparkClassLoader.getResource(replDefaultLogProps)) match { + case Some(url) => + PropertyConfigurator.configure(url) + System.err.println(s"Using Spark's repl log4j profile: $replDefaultLogProps") + System.err.println("To adjust logging level use sc.setLogLevel(\"INFO\")") + case None => + System.err.println(s"Spark was unable to load $replDefaultLogProps") + } + } else { + val defaultLogProps = "org/apache/spark/log4j-defaults.properties" + Option(Utils.getSparkClassLoader.getResource(defaultLogProps)) match { + case Some(url) => + PropertyConfigurator.configure(url) + System.err.println(s"Using Spark's default log4j profile: $defaultLogProps") + case None => + System.err.println(s"Spark was unable to load $defaultLogProps") + } } } } |