jwang0306 commented on PR #41302:
URL: https://github.com/apache/spark/pull/41302#issuecomment-1569028481
@dongjoon-hyun thanks for the suggestion, the variable is now renamed.
For (3), I think I slightly prefer adding a new field in `Logging` to check
whether the warning message is printed, so we could print the warning message
under the same condition. Does this sounds good to you?
```diff
diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala
b/core/src/main/scala/org/apache/spark/SparkContext.scala
index e142d79523..34fdd4fc32 100644
--- a/core/src/main/scala/org/apache/spark/SparkContext.scala
+++ b/core/src/main/scala/org/apache/spark/SparkContext.scala
@@ -396,7 +396,12 @@ class SparkContext(config: SparkConf) extends Logging {
try {
_conf = config.clone()
- _conf.get(SPARK_LOG_LEVEL).foreach(setLogLevel(_))
+ _conf.get(SPARK_LOG_LEVEL).foreach { level =>
+ if (Logging.setLogLevelPrinted) {
+ System.err.printf("Setting Spark log level to \"%s\".\n", level)
+ }
+ setLogLevel(level)
+ }
_conf.validateSettings()
_conf.set("spark.app.startTime", startTime.toString)
diff --git a/core/src/main/scala/org/apache/spark/internal/Logging.scala
b/core/src/main/scala/org/apache/spark/internal/Logging.scala
index 614103dee7..fa00783a9d 100644
--- a/core/src/main/scala/org/apache/spark/internal/Logging.scala
+++ b/core/src/main/scala/org/apache/spark/internal/Logging.scala
@@ -139,6 +139,7 @@ trait Logging {
context.setConfigLocation(url.toURI)
if (!silent) {
System.err.println(s"Using Spark's default log4j profile:
$defaultLogProps")
+ Logging.setLogLevelPrinted = true
}
case None =>
System.err.println(s"Spark was unable to load $defaultLogProps")
@@ -164,6 +165,7 @@ trait Logging {
System.err.printf("Setting default log level to \"%s\".\n",
replLevel)
System.err.println("To adjust logging level use
sc.setLogLevel(newLevel). " +
"For SparkR, use setLogLevel(newLevel).")
+ Logging.setLogLevelPrinted = true
}
Logging.sparkShellThresholdLevel = replLevel
rootLogger.getAppenders().asScala.foreach {
@@ -189,6 +191,7 @@ private[spark] object Logging {
@volatile private var defaultRootLevel: Level = null
@volatile private var defaultSparkLog4jConfig = false
@volatile private[spark] var sparkShellThresholdLevel: Level = null
+ @volatile var setLogLevelPrinted: Boolean = false
val initLock = new Object()
try {
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]