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


##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/LoggersTest.java:
##########
@@ -166,25 +175,32 @@ public void testSetLevel() {
 
     @Test
     public void testSetRootLevel() {
-        Logger root = logger("root");
-        root.setLevel(Level.ERROR);
-
-        Logger p = logger("a.b.c.p");
-        Logger x = logger("a.b.c.p.X");
-        Logger y = logger("a.b.c.p.Y");
-        Logger z = logger("a.b.c.p.Z");
-        Logger w = logger("a.b.c.s.W");
-        x.setLevel(Level.INFO);
-        y.setLevel(Level.INFO);
-        z.setLevel(Level.INFO);
-        w.setLevel(Level.INFO);
+        LoggerContext loggerContext = (LoggerContext) 
LogManager.getContext(false);
+        Configuration config = loggerContext.getConfiguration();
+        LoggerConfig rootConfig = new LoggerConfig("", Level.ERROR, false);
+        config.addLogger("", rootConfig);
+        loggerContext.updateLoggers();
+
+        Logger root = LogManager.getLogger("");
+        Configurator.setLevel(root, Level.ERROR);
+
+        Logger p = loggerContext.getLogger("a.b.c.p");
+        Logger x = loggerContext.getLogger("a.b.c.p.X");
+        Logger y = loggerContext.getLogger("a.b.c.p.Y");
+        Logger z = loggerContext.getLogger("a.b.c.p.Z");
+        Logger w = loggerContext.getLogger("a.b.c.s.W");
+        Configurator.setLevel(p, null);
+        Configurator.setLevel(x, Level.INFO);
+        Configurator.setLevel(y, Level.INFO);
+        Configurator.setLevel(z, Level.INFO);
+        Configurator.setLevel(w, Level.INFO);
 
         Loggers loggers = new TestLoggers(root, x, y, z, w);
 
-        List<String> modified = loggers.setLevel("root", Level.DEBUG);
-        assertEquals(Arrays.asList("a.b.c.p.X", "a.b.c.p.Y", "a.b.c.p.Z", 
"a.b.c.s.W", "root"), modified);
+        List<String> modified = loggers.setLevel("", Level.DEBUG);
+        assertEquals(Arrays.asList("", "a.b.c.p.X", "a.b.c.p.Y", "a.b.c.p.Z", 
"a.b.c.s.W"), modified);
 
-        assertNull(p.getLevel());
+        assertEquals(p.getLevel(), Level.DEBUG);

Review Comment:
   In Log4j2, the `getLevel` method returns either the explicitly set level or 
the effective level. We can roughly think of it as a combination of two methods 
(`getLevel` and `getEffectiveLevel`) from Log4j1.



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