viirya commented on a change in pull request #35080:
URL: https://github.com/apache/spark/pull/35080#discussion_r777144365



##########
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:
       The `LoggerConfig` instance of the logger is not changed. But it was 
called with `setLevel`. If the level was changed, we can tell the difference 
(the case 2), but if it was set to same level as before, we cannot know the 
difference.
   
   So, if a logger was custom configured (i.e. with a config in properties 
file, case 1), we can know it was configured.
   If not, but it was programmatically changed by `setLevel`, we can only know 
it was configured if the level is different (case 2).
   
   If a logger was not configured in properties file (not case 1, so now it is 
attached with root `LoggerConfig`), but it was called with `setLevel` with same 
level as root level (not case 2 because the level is not changed), we cannot 
tell it was configured or not (because its level isn't changed).
   
   




-- 
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]

Reply via email to