frankvicky commented on code in PR #17373:
URL: https://github.com/apache/kafka/pull/17373#discussion_r1812372794


##########
core/src/main/scala/kafka/utils/Log4jController.scala:
##########
@@ -17,83 +17,86 @@
 
 package kafka.utils
 
+import org.apache.logging.log4j.core.LoggerContext
+import org.apache.logging.log4j.core.config.Configurator
+import org.apache.logging.log4j.{Level, LogManager}
+
 import java.util
 import java.util.Locale
-
-import org.apache.kafka.common.utils.Utils
-import org.apache.log4j.{Level, LogManager, Logger}
-
-import scala.collection.mutable
 import scala.jdk.CollectionConverters._
 
 
 object Log4jController {
-  val ROOT_LOGGER = "root"
-
-  private def resolveLevel(logger: Logger): String = {
-    var name = logger.getName
-    var level = logger.getLevel
-    while (level == null) {
-      val index = name.lastIndexOf(".")
-      if (index > 0) {
-        name = name.substring(0, index)
-        val ancestor = existingLogger(name)
-        if (ancestor != null) {
-          level = ancestor.getLevel
-        }
-      } else {
-        level = existingLogger(ROOT_LOGGER).getLevel
-      }
-    }
-    level.toString
-  }
+
+  val ROOT_LOGGER = ""
 
   /**
-    * Returns a map of the log4j loggers and their assigned log level.
-    * If a logger does not have a log level assigned, we return the root 
logger's log level
-    */
-  def loggers: mutable.Map[String, String] = {
-    val logs = new mutable.HashMap[String, String]()
-    val rootLoggerLvl = existingLogger(ROOT_LOGGER).getLevel.toString
-    logs.put(ROOT_LOGGER, rootLoggerLvl)
-
-    val loggers = LogManager.getCurrentLoggers
-    while (loggers.hasMoreElements) {
-      val logger = loggers.nextElement().asInstanceOf[Logger]
-      if (logger != null) {
-        logs.put(logger.getName, resolveLevel(logger))
-      }
-    }
-    logs
+   * Returns given logger's parent's (or the first ancestor's) name.
+   *
+   * @throws IllegalArgumentException loggerName is null or empty.
+   */

Review Comment:
   Oops, I will do some clean-up



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

Reply via email to