In Java, what is the difference between a global logger and a root log?

In the Java class java.util.logging.Logger, what is the difference between global and root registrars? They are the same? The method Logger::getGlobalreturns the global registrar. When called Logger::getParentuntil the result is null, you get the root logger. When I call Logger::getLoggerwith an empty string for the name argument, does it return a global logger or root log?

http://docs.oracle.com/javase/9/docs/api/java/util/logging/Logger.html

+4
source share
1 answer

In the java.util.logging.Logger Java class, what is the difference between global and root registrars? They are the same?

No, they do not match.

public static void main(String[] args) throws Exception {
    System.out.println(Logger.getLogger(""));
    System.out.println(Logger.getGlobal());
    System.out.println(Logger.getGlobal().getParent());
}

, , :

java.util.logging.LogManager$RootLogger@27082746
java.util.logging.Logger@66133adc
java.util.logging.LogManager$RootLogger@27082746

, . , . - , . System.out , .

Logger:: getLogger name, ?

.

+2

Source: https://habr.com/ru/post/1694662/


All Articles