You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/01/01 21:50:02 UTC
[GitHub] [spark] sarutak commented on a change in pull request #35080: [SPARK-37792][CORE] Fix the check of custom configuration in SparkShellLoggingFilter
sarutak commented on a change in pull request #35080:
URL: https://github.com/apache/spark/pull/35080#discussion_r777138948
##########
File path: core/src/main/scala/org/apache/spark/internal/Logging.scala
##########
@@ -259,18 +259,25 @@ private[spark] object Logging {
} else if (logEvent.getLevel.isMoreSpecificThan(Logging.sparkShellThresholdLevel)) {
Filter.Result.NEUTRAL
} else {
- var logger = LogManager.getLogger(logEvent.getLoggerName)
- .asInstanceOf[Log4jLogger]
- while (logger.getParent() != null) {
- if (logger.getLevel != null || !logger.getAppenders.isEmpty) {
+ val logger = LogManager.getLogger(logEvent.getLoggerName).asInstanceOf[Log4jLogger]
+ if (loggerWithCustomConfig(logger)) {
return Filter.Result.NEUTRAL
- }
- logger = logger.getParent()
}
Filter.Result.DENY
}
}
+ // Return true if the logger has custom configuration. It depends on:
+ // 1. If the logger isn't attached with root logger config (i.e., with custom configuration), or
+ // 2. the logger level is different to root config level (i.e., it is changed programmingly).
+ //
+ // Note that if a logger is programmingly changed log level but set to same level as root config
Review comment:
In this case, the instance of `LoggerConfig` is different between the custom logger and root logger?
Then, can we tell them each other?
##########
File path: core/src/main/scala/org/apache/spark/internal/Logging.scala
##########
@@ -259,18 +259,25 @@ private[spark] object Logging {
} else if (logEvent.getLevel.isMoreSpecificThan(Logging.sparkShellThresholdLevel)) {
Filter.Result.NEUTRAL
} else {
- var logger = LogManager.getLogger(logEvent.getLoggerName)
- .asInstanceOf[Log4jLogger]
- while (logger.getParent() != null) {
- if (logger.getLevel != null || !logger.getAppenders.isEmpty) {
+ val logger = LogManager.getLogger(logEvent.getLoggerName).asInstanceOf[Log4jLogger]
+ if (loggerWithCustomConfig(logger)) {
return Filter.Result.NEUTRAL
- }
- logger = logger.getParent()
}
Filter.Result.DENY
}
}
+ // Return true if the logger has custom configuration. It depends on:
+ // 1. If the logger isn't attached with root logger config (i.e., with custom configuration), or
+ // 2. the logger level is different to root config level (i.e., it is changed programmingly).
Review comment:
`programmingly` -> `programmatically`?
##########
File path: core/src/main/scala/org/apache/spark/internal/Logging.scala
##########
@@ -259,18 +259,25 @@ private[spark] object Logging {
} else if (logEvent.getLevel.isMoreSpecificThan(Logging.sparkShellThresholdLevel)) {
Filter.Result.NEUTRAL
} else {
- var logger = LogManager.getLogger(logEvent.getLoggerName)
- .asInstanceOf[Log4jLogger]
- while (logger.getParent() != null) {
- if (logger.getLevel != null || !logger.getAppenders.isEmpty) {
+ val logger = LogManager.getLogger(logEvent.getLoggerName).asInstanceOf[Log4jLogger]
+ if (loggerWithCustomConfig(logger)) {
return Filter.Result.NEUTRAL
- }
- logger = logger.getParent()
}
Filter.Result.DENY
}
}
+ // Return true if the logger has custom configuration. It depends on:
+ // 1. If the logger isn't attached with root logger config (i.e., with custom configuration), or
+ // 2. the logger level is different to root config level (i.e., it is changed programmingly).
+ //
+ // Note that if a logger is programmingly changed log level but set to same level as root config
+ // level, we cannot tell if it is with custom configuration.
+ private def loggerWithCustomConfig(logger: Log4jLogger): Boolean = {
+ val rootConfig = LogManager.getRootLogger.asInstanceOf[Log4jLogger].get()
+ logger.get() != rootConfig || logger.getLevel != rootConfig.getLevel()
Review comment:
Is it possible that `logger.get() != rootConfig` is `false` but `logger.getLevel != rootConfig.getLevel()` is `true`?
Can we check with `logger.get ne rootConfig` instead ?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org