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 namedLogger
within 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), andHandler
objects from their ancestors in the hierarchy and, ultimately, from the rootLogger
defined by the globalLogManager
.Applets that require a
Logger
with no security restrictions should use the staticgetAnonymousLogger( )
method to create an unnamedLogger
that is not part of the hierarchy of namedLogger
objects managed by theLogManager
. ALogger
created by this method has theLogManager
root logger as its parent, and inherits the logging level and handlers of that root logger.Finally, the static
Logger.global
field refers to a pre-definedLogger
named “global”; programmers may find this pre-definedLogger
convenient 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. ...
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.