System
public static interface System.Logger
System.Logger
instances log messages that will be routed to the underlying logging framework the LoggerFinder
uses. System.Logger
instances are typically obtained from the System
class, by calling System.getLogger(loggerName)
or System.getLogger(loggerName, bundle)
.Modifier and Type | Interface | Description |
---|---|---|
static enum |
System.Logger.Level |
System loggers levels. |
Modifier and Type | Method | Description |
---|---|---|
String |
getName() |
Returns the name of this logger. |
boolean |
isLoggable |
Checks if a message of the given level would be logged by this logger. |
default void |
log |
Logs a message produced from the given object. |
default void |
log |
Logs a message. |
default void |
log |
Logs a message with an optional list of parameters. |
default void |
log |
Logs a message associated with a given throwable. |
default void |
log |
Logs a lazily supplied message. |
default void |
log |
Logs a lazily supplied message associated with a given throwable. |
void |
log |
Logs a message with resource bundle and an optional list of parameters. |
void |
log |
Logs a localized message associated with a given throwable. |
String getName()
boolean isLoggable(System.Logger.Level level)
level
- the log message level.true
if the given log message level is currently being logged.NullPointerException
- if level
is null
.default void log(System.Logger.Level level, String msg)
this.log(level, (ResourceBundle)null, msg, (Object[])null);
level
- the log message level.msg
- the string message (or a key in the message catalog, if this logger is a localized logger
); can be null
.NullPointerException
- if level
is null
.default void log(System.Logger.Level level, Supplier<String> msgSupplier)
this.log(level, (ResourceBundle)null, msgSupplier.get(), (Object[])null);
level
- the log message level.msgSupplier
- a supplier function that produces a message.NullPointerException
- if level
is null
, or msgSupplier
is null
.default void log(System.Logger.Level level, Object obj)
this.log(level, (ResourceBundle)null, obj.toString(), (Object[])null);
level
- the log message level.obj
- the object to log.NullPointerException
- if level
is null
, or obj
is null
.default void log(System.Logger.Level level, String msg, Throwable thrown)
this.log(level, (ResourceBundle)null, msg, thrown);
level
- the log message level.msg
- the string message (or a key in the message catalog, if this logger is a localized logger
); can be null
.thrown
- a Throwable
associated with the log message; can be null
.NullPointerException
- if level
is null
.default void log(System.Logger.Level level, Supplier<String> msgSupplier, Throwable thrown)
this.log(level, (ResourceBundle)null, msgSupplier.get(), thrown);
level
- one of the log message level identifiers.msgSupplier
- a supplier function that produces a message.thrown
- a Throwable
associated with log message; can be null
.NullPointerException
- if level
is null
, or msgSupplier
is null
.default void log(System.Logger.Level level, String format, Object... params)
this.log(level, (ResourceBundle)null, format, params);
level
- one of the log message level identifiers.format
- the string message format in MessageFormat
format, (or a key in the message catalog, if this logger is a localized logger
); can be null
.params
- an optional list of parameters to the message (may be none).NullPointerException
- if level
is null
.void log(System.Logger.Level level, ResourceBundle bundle, String msg, Throwable thrown)
null
, the msg
string is localized using the given resource bundle. Otherwise the msg
string is not localized.level
- the log message level.bundle
- a resource bundle to localize msg
; can be null
.msg
- the string message (or a key in the message catalog, if bundle
is not null
); can be null
.thrown
- a Throwable
associated with the log message; can be null
.NullPointerException
- if level
is null
.void log(System.Logger.Level level, ResourceBundle bundle, String format, Object... params)
null
, the format
string is localized using the given resource bundle. Otherwise the format
string is not localized.level
- the log message level.bundle
- a resource bundle to localize format
; can be null
.format
- the string message format in MessageFormat
format, (or a key in the message catalog if bundle
is not null
); can be null
.params
- an optional list of parameters to the message (may be none).NullPointerException
- if level
is null
.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/System.Logger.html