This is an automated email from the ASF dual-hosted git repository.

chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 6bbe144004e MINOR: Move LoggingController log level resolution test to 
server (#22402)
6bbe144004e is described below

commit 6bbe144004eaffa853d3ba89b48d72bcce01839c
Author: majialong <[email protected]>
AuthorDate: Thu Jun 25 04:01:15 2026 +0800

    MINOR: Move LoggingController log level resolution test to server (#22402)
    
    `LoggingController` now lives in the `server` module, but its direct log
    level resolution test was still under `core`. This PR moves that test to
    `server` and rewrites it in Java.
    
    Reviewers: Russole <[email protected]>, Ken Huang
     <[email protected]>, Chia-Ping Tsai <[email protected]>
---
 core/src/test/scala/kafka/utils/LoggingTest.scala  | 20 ----------
 .../kafka/server/logger/LoggingControllerTest.java | 46 ++++++++++++++++++++++
 2 files changed, 46 insertions(+), 20 deletions(-)

diff --git a/core/src/test/scala/kafka/utils/LoggingTest.scala 
b/core/src/test/scala/kafka/utils/LoggingTest.scala
index 761b276c400..e07087b7386 100644
--- a/core/src/test/scala/kafka/utils/LoggingTest.scala
+++ b/core/src/test/scala/kafka/utils/LoggingTest.scala
@@ -17,13 +17,11 @@
 
 package kafka.utils
 
-import org.apache.kafka.server.logger.LoggingController
 import java.lang.management.ManagementFactory
 
 import javax.management.ObjectName
 import org.junit.jupiter.api.Test
 import org.junit.jupiter.api.Assertions.{assertEquals, assertTrue}
-import org.slf4j.LoggerFactory
 
 class LoggingTest extends Logging {
 
@@ -60,22 +58,4 @@ class LoggingTest extends Logging {
 
     assertEquals(logging.getClass.getName, logging.log.underlying.getName)
   }
-
-  @Test
-  def testLoggerLevelIsResolved(): Unit = {
-    val controller = new LoggingController()
-    val previousLevel = controller.getLogLevel("kafka")
-    try {
-      controller.setLogLevel("kafka", "TRACE")
-      // Do some logging so that the Logger is created within the hierarchy
-      // (until loggers are used only loggers in the config file exist)
-      LoggerFactory.getLogger("kafka.utils.Log4jControllerTest").trace("test")
-      assertEquals("TRACE", controller.getLogLevel("kafka"))
-      assertEquals("TRACE", 
controller.getLogLevel("kafka.utils.Log4jControllerTest"))
-      assertTrue(controller.getLoggers.contains("kafka=TRACE"))
-      
assertTrue(controller.getLoggers.contains("kafka.utils.Log4jControllerTest=TRACE"))
-    } finally {
-      controller.setLogLevel("kafka", previousLevel)
-    }
-  }
 }
diff --git 
a/server/src/test/java/org/apache/kafka/server/logger/LoggingControllerTest.java
 
b/server/src/test/java/org/apache/kafka/server/logger/LoggingControllerTest.java
new file mode 100644
index 00000000000..18b58e216c1
--- /dev/null
+++ 
b/server/src/test/java/org/apache/kafka/server/logger/LoggingControllerTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.server.logger;
+
+import org.junit.jupiter.api.Test;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class LoggingControllerTest {
+
+    @Test
+    public void testLoggerLevelIsResolved() {
+        LoggingController controller = new LoggingController();
+        String loggerName = "org.apache.kafka";
+        String childLoggerName = 
"org.apache.kafka.server.logger.LoggingControllerTest";
+        String previousLevel = controller.getLogLevel(loggerName);
+        try {
+            controller.setLogLevel(loggerName, "TRACE");
+            // Do some logging so that the Logger is created within the 
hierarchy
+            // (until loggers are used only loggers in the config file exist).
+            LoggerFactory.getLogger(childLoggerName).trace("test");
+            assertEquals("TRACE", controller.getLogLevel(loggerName));
+            assertEquals("TRACE", controller.getLogLevel(childLoggerName));
+            assertTrue(controller.getLoggers().contains(loggerName + 
"=TRACE"));
+            assertTrue(controller.getLoggers().contains(childLoggerName + 
"=TRACE"));
+        } finally {
+            controller.setLogLevel(loggerName, previousLevel);
+        }
+    }
+}

Reply via email to