In Java 9, PlatformLoggingAPI is available via Services Record messages The interface of the consumer of these messages. The implementation of LoggerFinder has been loaded using System ClassLoader with the help of java.util.ServiceLoader API . Based on this implementation, applications can plug in their own external logging backend without having to configure java.util.logging.
We can pass a class name or module to LoggerFinder so that it knows which logger to return.
<strong>public class MyLoggerFinder extends LoggerFinder { @Override public Logger getLogger(String name, Module module) { // return a logger depends on name/module } }</strong>
If no specific implementation is found, the default LoggerFinder implementation is used. We create the logger from the LoggerFinder by using the Factorymethod of the System class.
<strong>public class System { System.Logger getLogger(String name) { } System.Logger getLogger(String name, ResourceBundle bundle) { } }</strong>
The above is the detailed content of What is the platform logging API in Java 9?. For more information, please follow other related articles on the PHP Chinese website!