java.lang.Object | +--java.util.logging.Logger
static java.util.logging.Logger | global A logger provided to applications that make only occasional use of the logging framework, typically early prototypes. |
Logger(java.lang.String name, java.lang.String resourceBundleName) Constructs a Logger for a subsystem. |
synchronized void | addHandler(java.util.logging.Handler handler) Adds a handler to the set of handlers that get notified when a log record is to be published. |
synchronized void | config(java.lang.String message) Logs a message with severity level CONFIG. |
synchronized void | entering(java.lang.String sourceClass, java.lang.String sourceMethod) |
synchronized void | entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object param) |
synchronized void | entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object[] params) |
synchronized void | exiting(java.lang.String sourceClass, java.lang.String sourceMethod) |
synchronized void | exiting(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object result) |
synchronized void | fine(java.lang.String message) Logs a message with severity level FINE. |
synchronized void | finer(java.lang.String message) Logs a message with severity level FINER. |
synchronized void | finest(java.lang.String message) Logs a message with severity level FINEST. |
static java.util.logging.Logger | getAnonymousLogger() Creates a new, unnamed logger. |
static java.util.logging.Logger | getAnonymousLogger(java.lang.String resourceBundleName) Creates a new, unnamed logger. |
synchronized java.util.logging.Filter | getFilter() |
synchronized java.util.logging.Handler[] | getHandlers() Returns the handlers currently registered for this Logger. |
synchronized java.util.logging.Level | getLevel() Returns the severity level threshold for this |
static java.util.logging.Logger | getLogger(java.lang.String name) Finds a registered logger for a subsystem, or creates one in case no logger has been registered yet. |
static java.util.logging.Logger | getLogger(java.lang.String name, java.lang.String resourceBundleName) Finds a registered logger for a subsystem, or creates one in case no logger has been registered yet. |
java.lang.String | getName() Returns the name of this logger. |
synchronized java.util.logging.Logger | getParent() Returns the parent of this logger. |
synchronized java.util.ResourceBundle | getResourceBundle() Returns the resource bundle that is being used for localizing messages. |
synchronized java.lang.String | getResourceBundleName() Returns the name of the resource bundle that is being used for localizing messages. |
synchronized boolean | getUseParentHandlers() Returns whether or not this Logger forwards log records to handlers registered for its parent loggers. |
synchronized void | info(java.lang.String message) Logs a message with severity level INFO. |
synchronized boolean | isLoggable(java.util.logging.Level level) Returns whether or not a message of the specified level would be logged by this logger. |
synchronized void | log(java.util.logging.LogRecord record) Passes a record to registered handlers, provided the record is considered as loggable both by #isLoggable(Level) and a possibly installed custom #setFilter(Filter) filter. |
void | log(java.util.logging.Level level, java.lang.String message) |
synchronized void | log(java.util.logging.Level level, java.lang.String message, java.lang.Object param) |
synchronized void | log(java.util.logging.Level level, java.lang.String message, java.lang.Object[] params) |
synchronized void | log(java.util.logging.Level level, java.lang.String message, java.lang.Throwable thrown) |
synchronized void | logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String message) |
synchronized void | logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String message, java.lang.Object param) |
synchronized void | logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String message, java.lang.Object[] params) |
synchronized void | logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String message, java.lang.Throwable thrown) |
synchronized void | logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String message) |
synchronized void | logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String message, java.lang.Object param) |
synchronized void | logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String message, java.lang.Object[] params) |
synchronized void | logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String message, java.lang.Throwable thrown) |
synchronized void | removeHandler(java.util.logging.Handler handler) Removes a handler from the set of handlers that get notified when a log record is to be published. |
synchronized void | setFilter(java.util.logging.Filter filter) |
synchronized void | setLevel(java.util.logging.Level level) Sets the severity level threshold for this |
synchronized void | setParent(java.util.logging.Logger parent) Sets the parent of this logger. |
synchronized void | setUseParentHandlers(boolean useParentHandlers) Sets whether or not this Logger forwards log records to handlers registered for its parent loggers. |
synchronized void | severe(java.lang.String message) Logs a message with severity level SEVERE, indicating a serious failure that prevents normal program execution. |
synchronized void | throwing(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Throwable thrown) |
synchronized void | warning(java.lang.String message) Logs a message with severity level WARNING, indicating a potential problem that does not prevent normal program execution. |
public static final Logger global
protected Logger(java.lang.String name, java.lang.String resourceBundleName)
name
- the name for the logger, for example "java.awt"
or "com.foo.bar".resourceBundleName
- the name of a resource bundle
for localizing messages, or null
to indicate that messages do not need to be localized.MissingResourceException
- if
resourceBundleName
is not null
and no such bundle could be located.public synchronized void addHandler(java.util.logging.Handler handler)
handler
- the handler to be added.NullPointerException
- if handler
is null
.SecurityException
- if this logger is not anonymous, a
security manager exists, and the caller is not granted
the permission to control the logging infrastructure by
having LoggingPermission("control").public synchronized void config(java.lang.String message)
message
- the message text, also used as look-up key if the
logger is localizing messages with a resource bundle.public synchronized void entering(java.lang.String sourceClass, java.lang.String sourceMethod)
Parameters:sourceClass
- sourceMethod
- public synchronized void entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object param)
Parameters:sourceClass
- sourceMethod
- param
- public synchronized void entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object[] params)
Parameters:sourceClass
- sourceMethod
- params
- public synchronized void exiting(java.lang.String sourceClass, java.lang.String sourceMethod)
Parameters:sourceClass
- sourceMethod
- public synchronized void exiting(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object result)
Parameters:sourceClass
- sourceMethod
- result
- public synchronized void fine(java.lang.String message)
message
- the message text, also used as look-up key if the
logger is localizing messages with a resource
bundle.public synchronized void finer(java.lang.String message)
message
- the message text, also used as look-up key if the
logger is localizing messages with a resource
bundle.public synchronized void finest(java.lang.String message)
message
- the message text, also used as look-up key if the
logger is localizing messages with a resource
bundle.public static Logger getAnonymousLogger()
The parent of the newly created logger will the the root logger, from which the level threshold and the handlers are inherited.
public static Logger getAnonymousLogger(java.lang.String resourceBundleName)
The parent of the newly created logger will the the root logger, from which the level threshold and the handlers are inherited.
resourceBundleName
- the name of a resource bundle
for localizing messages, or null
to indicate that messages do not need to be localized.MissingResourceException
- if
resourceBundleName
is not null
and no such bundle could be located.public synchronized Filter getFilter()
public synchronized Handler[] getHandlers()
public synchronized Level getLevel()
Handler
.
All log records with a lower severity level will be discarded;
a log record of the same or a higher level will be published
unless an installed Filter
decides to discard it.
null
if the logger inherits
the threshold from its parent.public static Logger getLogger(java.lang.String name)
name
- the name for the logger, for example "java.awt"
or "com.foo.bar".name
that does not localize messages.IllegalArgumentException
- if a logger for the subsystem
identified by name
has already been created,
but uses a a resource bundle for localizing messages.NullPointerException
- if name
is
null
.public static Logger getLogger(java.lang.String name, java.lang.String resourceBundleName)
If a logger with the specified name has already been registered, the behavior depends on the resource bundle that is currently associated with the existing logger.
resourceBundleName
, the existing logger
is returned.resourceBundleName
. The existing logger is then
returned. Therefore, all subsystems currently using this logger
will produce localized messages from now on.resourceBundleName
, an
IllegalArgumentException
is thrown.name
- the name for the logger, for example "java.awt"
or "org.gnu.foo".resourceBundleName
- the name of a resource bundle
for localizing messages, or null
to indicate that messages do not need to be localized.name
.MissingResourceException
- if
resourceBundleName
is not null
and no such bundle could be located.IllegalArgumentException
- if a logger for the subsystem
identified by name
has already been created,
but uses a different resource bundle for localizing
messages.NullPointerException
- if name
is
null
.public String getName()
null
if
the logger is anonymous.public synchronized Logger getParent()
null
for the root logger.public synchronized ResourceBundle getResourceBundle()
null
if the parent's resource bundle
is used for this purpose.public synchronized String getResourceBundleName()
null
if the parent's resource bundle
is used for this purpose.public synchronized boolean getUseParentHandlers()
false
if this Logger sends log records
merely to Handlers registered with itself;
true
if this Logger sends log records
not only to Handlers registered with itself, but also
to those Handlers registered with parent loggers.public synchronized void info(java.lang.String message)
message
- the message text, also used as look-up key if the
logger is localizing messages with a resource
bundle.public synchronized boolean isLoggable(java.util.logging.Level level)
level
- NullPointerException
- if level
is null
.public void log(java.util.logging.Level level, java.lang.String message)
Parameters:level
- message
- public synchronized void log(java.util.logging.Level level, java.lang.String message, java.lang.Object param)
Parameters:level
- message
- param
- public synchronized void log(java.util.logging.Level level, java.lang.String message, java.lang.Object[] params)
Parameters:level
- message
- params
- public synchronized void log(java.util.logging.Level level, java.lang.String message, java.lang.Throwable thrown)
Parameters:level
- message
- thrown
- public synchronized void log(java.util.logging.LogRecord record)
If the logger has been configured to use parent handlers, the record will be forwarded to the parent of this logger in addition to being processed by the handlers registered with this logger.
The other logging methods in this class are convenience methods that merely create a new LogRecord and pass it to this method. Therefore, subclasses usually just need to override this single method for customizing the logging behavior.
record
- the log record to be inspected and possibly forwarded.public synchronized void logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String message)
Parameters:level
- sourceClass
- sourceMethod
- message
- public synchronized void logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String message, java.lang.Object param)
Parameters:level
- sourceClass
- sourceMethod
- message
- param
- public synchronized void logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String message, java.lang.Object[] params)
Parameters:level
- sourceClass
- sourceMethod
- message
- params
- public synchronized void logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String message, java.lang.Throwable thrown)
Parameters:level
- sourceClass
- sourceMethod
- message
- thrown
- public synchronized void logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String message)
Parameters:level
- sourceClass
- sourceMethod
- bundleName
- message
- public synchronized void logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String message, java.lang.Object param)
Parameters:level
- sourceClass
- sourceMethod
- bundleName
- message
- param
- public synchronized void logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String message, java.lang.Object[] params)
Parameters:level
- sourceClass
- sourceMethod
- bundleName
- message
- params
- public synchronized void logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String message, java.lang.Throwable thrown)
Parameters:level
- sourceClass
- sourceMethod
- bundleName
- message
- thrown
- public synchronized void removeHandler(java.util.logging.Handler handler)
handler
- the handler to be removed.SecurityException
- if this logger is not anonymous, a
security manager exists, and the caller is not granted the
permission to control the logging infrastructure by having
LoggingPermission("control").NullPointerException
- if handler
is null
.public synchronized void setFilter(java.util.logging.Filter filter)
filter
- SecurityException
- if this logger is not anonymous, a
security manager exists, and the caller is not granted
the permission to control the logging infrastructure by
having LoggingPermission("control").public synchronized void setLevel(java.util.logging.Level level)
Handler
.
All log records with a lower severity level will be discarded
immediately. A log record of the same or a higher level will be
published unless an installed Filter
decides to
discard it.
#getAnonymousLogger(java.lang.String) getAnonymousLogger.
level
- the severity level below which all log messages
will be discarded, or null
to
indicate that the logger should inherit the
threshold from its parent.SecurityException
- if this logger is not anonymous, a
security manager exists, and the caller is not granted
the permission to control the logging infrastructure by
having LoggingPermission("control").public synchronized void setParent(java.util.logging.Logger parent)
parent
- NullPointerException
- if parent
is
null
.SecurityException
- if this logger is not anonymous, a
security manager exists, and the caller is not granted
the permission to control the logging infrastructure by
having LoggingPermission("control").public synchronized void setUseParentHandlers(boolean useParentHandlers)
useParentHandlers
- false to let this
Logger send log records merely to Handlers registered
with itself; true
to let this Logger
send log records not only to Handlers registered
with itself, but also to those Handlers registered with
parent loggers.SecurityException
- if this logger is not anonymous, a
security manager exists, and the caller is not granted
the permission to control the logging infrastructure by
having LoggingPermission("control").public synchronized void severe(java.lang.String message)
message
- the message text, also used as look-up key if the
logger is localizing messages with a resource
bundle.public synchronized void throwing(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Throwable thrown)
Parameters:sourceClass
- sourceMethod
- thrown
- public synchronized void warning(java.lang.String message)
message
- the message text, also used as look-up key if the
logger is localizing messages with a resource
bundle.
It is common to name a logger after the name of a corresponding Java package. Loggers are organized into a hierarchical namespace; for example, the logger
"org.gnu.foo"
is the parent of logger"org.gnu.foo.bar"
.A logger for a named subsystem can be obtained through java.util.logging.Logger#getLogger(java.lang.String). However, only code which has been granted the permission to control the logging infrastructure will be allowed to customize that logger. Untrusted code can obtain a private, anonymous logger through #getAnonymousLogger() if it wants to perform any modifications to the logger.
FIXME: Write more documentation.