Name
Logger
Synopsis
A
Logger object is used
to emit log messages. Logger does not have a
public constructor, but there are several ways to obtain a
Logger object to use in your code:
Typically, applications call the static
getLogger( )method to create or lookup a namedLoggerwithin a hierarchy of named loggers. Loggers have dot-separated hierarchical names, which should be based on the name of the class or package that uses them. Loggers obtained in this way inherit their logging level, resource bundle (for localization), andHandlerobjects from their ancestors in the hierarchy and, ultimately, from the rootLoggerdefined by the globalLogManager.Applets that require a
Loggerwith no security restrictions should use the staticgetAnonymousLogger( )method to create an unnamedLoggerthat is not part of the hierarchy of namedLoggerobjects managed by theLogManager. ALoggercreated by this method has theLogManagerroot logger as its parent, and inherits the logging level and handlers of that root logger.Finally, the static
Logger.globalfield refers to a pre-definedLoggernamed “global”; programmers may find this pre-definedLoggerconvenient during the early stages of application development, but it should not be used in production code.
Once a suitable Logger has been obtained, there
are a variety of methods that can be used to create a log message:
The
log( )methods log a specified message at the specified level, with optional parameters that can be used in message localization. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access