Home > Java > javaTutorial > body text

What is the platform logging API in Java 9?

王林
Release: 2023-09-14 16:33:03
forward
658 people have browsed it

Java 9中的平台日志API是什么?

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>
Copy after login

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>
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!