You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by an...@apache.org on 2015/06/10 22:26:41 UTC
spark git commit: [SPARK-7261] [CORE] Change default log level to
WARN in the REPL
Repository: spark
Updated Branches:
refs/heads/master e90c9d92d -> 80043e9e7
[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 <zs...@gmail.com>
Closes #6734 from zsxwing/log4j-repl and squashes the following commits:
3835eff [zsxwing] Change default log level to WARN in the REPL
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/80043e9e
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/80043e9e
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/80043e9e
Branch: refs/heads/master
Commit: 80043e9e761c44ce2c3a432dcd1989be573f8bb4
Parents: e90c9d9
Author: zsxwing <zs...@gmail.com>
Authored: Wed Jun 10 13:25:59 2015 -0700
Committer: Andrew Or <an...@databricks.com>
Committed: Wed Jun 10 13:26:33 2015 -0700
----------------------------------------------------------------------
.rat-excludes | 1 +
.../apache/spark/log4j-defaults-repl.properties | 12 +++++++++
.../main/scala/org/apache/spark/Logging.scala | 26 ++++++++++++++------
3 files changed, 32 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/80043e9e/.rat-excludes
----------------------------------------------------------------------
diff --git a/.rat-excludes b/.rat-excludes
index 994c7e8..aa008e6 100644
--- a/.rat-excludes
+++ b/.rat-excludes
@@ -28,6 +28,7 @@ spark-env.sh
spark-env.cmd
spark-env.sh.template
log4j-defaults.properties
+log4j-defaults-repl.properties
bootstrap-tooltip.js
jquery-1.11.1.min.js
d3.min.js
http://git-wip-us.apache.org/repos/asf/spark/blob/80043e9e/core/src/main/resources/org/apache/spark/log4j-defaults-repl.properties
----------------------------------------------------------------------
diff --git a/core/src/main/resources/org/apache/spark/log4j-defaults-repl.properties b/core/src/main/resources/org/apache/spark/log4j-defaults-repl.properties
new file mode 100644
index 0000000..b146f8a
--- /dev/null
+++ b/core/src/main/resources/org/apache/spark/log4j-defaults-repl.properties
@@ -0,0 +1,12 @@
+# Set everything to be logged to the console
+log4j.rootCategory=WARN, console
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.target=System.err
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
+
+# Settings to quiet third party logs that are too verbose
+log4j.logger.org.spark-project.jetty=WARN
+log4j.logger.org.spark-project.jetty.util.component.AbstractLifeCycle=ERROR
+log4j.logger.org.apache.spark.repl.SparkIMain$exprTyper=INFO
+log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=INFO
http://git-wip-us.apache.org/repos/asf/spark/blob/80043e9e/core/src/main/scala/org/apache/spark/Logging.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/org/apache/spark/Logging.scala b/core/src/main/scala/org/apache/spark/Logging.scala
index 419d093..7fcb783 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")
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org