System.Logger--the minimalistic logging interface in Java 9

Java 9 comes with a minimal logging interface: System.Logger with default implementation returned by System#getLogger:


@Test
public void log() {
    System.Logger LOG = System.getLogger(LoggerTest.class.getName());
    System.out.println("Default System.Logger implementation: " + LOG.getClass().getName());
    LOG.log(System.Logger.Level.INFO, "hello java 9 logging");
}

output:

    Default System.Logger implementation: sun.util.logging.internal.LoggingProviderImpl$JULWrapper
    Nov 01, 2017 5:56:46 AM com.airhacks.logging.LoggerTest log
    INFO: hello java 9 logging

See you at Java EE 8 on Java 9, at Munich Airport, Terminal 2

Comments:

People may start to this as a new general purpose logging facade, i.e. it will replace slf4j or similar. This is not strange as the authors of JEP-264 do in fact use the word "logging facade" themselves. However the JEP-264 also states that "It is not a goal to define a general-purpose interface for logging. The service interface contains only the minimal set of methods that the JDK needs for its own usage." In other words: the authors do not think this is interesting except for those who develop the JDK itself. Or how else to interpret this?

Posted by Lars Bruun on November 01, 2017 at 12:38 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments
License