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


NEW online workshop: WebStandards Igniter (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

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
realworldpatterns.com
Online Workshops
...the last 150 posts
...the last 10 comments
License