- java.lang.Object
- 
- java.lang.System.LoggerFinder
 
- 
- Enclosing class:
- System
 
 public abstract static class System.LoggerFinder extends Object TheLoggerFinderservice is responsible for creating, managing, and configuring loggers to the underlying framework it uses. A logger finder is a concrete implementation of this class that has a zero-argument constructor and implements the abstract methods defined by this class. The loggers returned from a logger finder are capable of routing log messages to the logging backend this provider supports. A given invocation of the Java Runtime maintains a single system-wide LoggerFinder instance that is loaded as follows:- First it finds any custom LoggerFinderprovider using theServiceLoaderfacility with the system class loader.
- If no LoggerFinderprovider is found, the system defaultLoggerFinderimplementation will be used.
 An application can replace the logging backend even when the java.logging module is present, by simply providing and declaring an implementation of the System.LoggerFinderservice.Default Implementation The system default LoggerFinderimplementation usesjava.util.loggingas the backend framework when thejava.loggingmodule is present. It returns a logger instance that will route log messages to ajava.util.logging.Logger. Otherwise, ifjava.loggingis not present, the default implementation will return a simple logger instance that will route log messages ofINFOlevel and above to the console (System.err).Logging Configuration Logger instances obtained from the LoggerFinderfactory methods are not directly configurable by the application. Configuration is the responsibility of the underlying logging backend, and usually requires using APIs specific to that backend.For the default LoggerFinderimplementation usingjava.util.loggingas its backend, refer tojava.util.loggingfor logging configuration. For the defaultLoggerFinderimplementation returning simple loggers when thejava.loggingmodule is absent, the configuration is implementation dependent.Usually an application that uses a logging framework will log messages through a logger facade defined (or supported) by that framework. Applications that wish to use an external framework should log through the facade associated with that framework. A system class that needs to log messages will typically obtain a System.Loggerinstance to route messages to the logging framework selected by the application.Libraries and classes that only need loggers to produce log messages should not attempt to configure loggers by themselves, as that would make them dependent from a specific implementation of the LoggerFinderservice.In addition, when a security manager is present, loggers provided to system classes should not be directly configurable through the logging backend without requiring permissions. 
 It is the responsibility of the provider of the concreteLoggerFinderimplementation to ensure that these loggers are not configured by untrusted code without proper permission checks, as configuration performed on such loggers usually affects all applications in the same Java Runtime.Message Levels and Mapping to backend levels A logger finder is responsible for mapping from a System.Logger.Levelto a level supported by the logging backend it uses.
 The default LoggerFinder usingjava.util.loggingas the backend mapsSystem.Loggerlevels to java.util.logging levels of corresponding severity - as described inLogger.Level.- Since:
- 9
- See Also:
- System,- System.Logger
 
- 
- 
Constructor SummaryConstructors Modifier Constructor Description protectedLoggerFinder()Creates a new instance ofLoggerFinder.
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description System.LoggergetLocalizedLogger(String name, ResourceBundle bundle, Module module)Returns a localizable instance ofLoggerfor the givenmodule.abstract System.LoggergetLogger(String name, Module module)Returns an instance ofLoggerfor the givenmodule.static System.LoggerFindergetLoggerFinder()Returns theLoggerFinderinstance.
 
- 
- 
- 
Constructor Detail- 
LoggerFinderprotected LoggerFinder() Creates a new instance ofLoggerFinder.- Implementation Note:
- It is recommended that a LoggerFinderservice implementation does not perform any heavy initialization in its constructor, in order to avoid possible risks of deadlock or class loading cycles during the instantiation of the service provider.
- Throws:
- SecurityException- if a security manager is present and its- checkPermissionmethod doesn't allow the- RuntimePermission("loggerFinder").
 
 
- 
 - 
Method Detail- 
getLoggerpublic abstract System.Logger getLogger(String name, Module module) Returns an instance ofLoggerfor the givenmodule.- Parameters:
- name- the name of the logger.
- module- the module for which the logger is being requested.
- Returns:
- a loggersuitable for use within the given module.
- Throws:
- NullPointerException- if- nameis- nullor- moduleis- null.
- SecurityException- if a security manager is present and its- checkPermissionmethod doesn't allow the- RuntimePermission("loggerFinder").
 
 - 
getLocalizedLoggerpublic System.Logger getLocalizedLogger(String name, ResourceBundle bundle, Module module) Returns a localizable instance ofLoggerfor the givenmodule. The returned logger will use the provided resource bundle for message localization.- Implementation Requirements:
- By default, this method calls this.getLogger(name, module)to obtain a logger, then wraps that logger in aSystem.Loggerinstance where all methods that do not take aResourceBundleas parameter are redirected to one which does - passing the givenbundlefor localization. So for instance, a call toLogger.log(Level.INFO, msg)will end up as a call toLogger.log(Level.INFO, bundle, msg, (Object[])null)on the wrapped logger instance. Note however that by default, string messages returned bySupplier<String>will not be localized, as it is assumed that such strings are messages which are already constructed, rather than keys in a resource bundle.An implementation of LoggerFindermay override this method, for example, when the underlying logging backend provides its own mechanism for localizing log messages, then such aLoggerFinderwould be free to return a logger that makes direct use of the mechanism provided by the backend.
- Parameters:
- name- the name of the logger.
- bundle- a resource bundle; can be- null.
- module- the module for which the logger is being requested.
- Returns:
- an instance of Loggerwhich will use the provided resource bundle for message localization.
- Throws:
- NullPointerException- if- nameis- nullor- moduleis- null.
- SecurityException- if a security manager is present and its- checkPermissionmethod doesn't allow the- RuntimePermission("loggerFinder").
 
 - 
getLoggerFinderpublic static System.LoggerFinder getLoggerFinder() Returns theLoggerFinderinstance. There is one single system-wideLoggerFinderinstance in the Java Runtime. See the class specification of how theLoggerFinderimplementation is located and loaded.- Returns:
- the LoggerFinderinstance.
- Throws:
- SecurityException- if a security manager is present and its- checkPermissionmethod doesn't allow the- RuntimePermission("loggerFinder").
 
 
- 
 
-