System.Logger (Java SE 13 & JDK 13 )
- Enclosing class:
- System
public static interface System.Logger
-
Nested Class Summary
-
Method Summary
Modifier and Type Method Description StringgetName()Returns the name of this logger.
booleanisLoggable(System.Logger.Level level)Checks if a message of the given level would be logged by this logger.
default voidlog(System.Logger.Level level, Object obj)Logs a message produced from the given object.
default voidlog(System.Logger.Level level, String msg)Logs a message.
default voidlog(System.Logger.Level level, String format, Object... params)Logs a message with an optional list of parameters.
default voidlog(System.Logger.Level level, String msg, Throwable thrown)Logs a message associated with a given throwable.
default voidlog(System.Logger.Level level, Supplier<String> msgSupplier)Logs a lazily supplied message.
default voidlog(System.Logger.Level level, Supplier<String> msgSupplier, Throwable thrown)Logs a lazily supplied message associated with a given throwable.
voidlog(System.Logger.Level level, ResourceBundle bundle, String format, Object... params)Logs a message with resource bundle and an optional list of parameters.
voidlog(System.Logger.Level level, ResourceBundle bundle, String msg, Throwable thrown)Logs a localized message associated with a given throwable.
-
Method Details
-
getName
Returns the name of this logger.
- Returns:
- the logger name.
-
isLoggable
Checks if a message of the given level would be logged by this logger.
- Parameters:
level- the log message level.- Returns:
trueif the given log message level is currently being logged.- Throws:
NullPointerException- iflevelisnull.
-
log
Logs a message.
- Implementation Requirements:
- The default implementation for this method calls
this.log(level, (ResourceBundle)null, msg, (Object[])null); - Parameters:
level- the log message level.msg- the string message (or a key in the message catalog, if this logger is alocalized logger); can benull.- Throws:
NullPointerException- iflevelisnull.
-
log
Logs a lazily supplied message. If the logger is currently enabled for the given log message level then a message is logged that is the result produced by the given supplier function. Otherwise, the supplier is not operated on.
- Implementation Requirements:
- When logging is enabled for the given level, the default
implementation for this method calls
this.log(level, (ResourceBundle)null, msgSupplier.get(), (Object[])null); - Parameters:
level- the log message level.msgSupplier- a supplier function that produces a message.- Throws:
NullPointerException- iflevelisnull, ormsgSupplierisnull.
-
log
Logs a message produced from the given object. If the logger is currently enabled for the given log message level then a message is logged that, by default, is the result produced from calling toString on the given object. Otherwise, the object is not operated on.
- Implementation Requirements:
- When logging is enabled for the given level, the default
implementation for this method calls
this.log(level, (ResourceBundle)null, obj.toString(), (Object[])null); - Parameters:
level- the log message level.obj- the object to log.- Throws:
NullPointerException- iflevelisnull, orobjisnull.
-
log
Logs a message associated with a given throwable.
- Implementation Requirements:
- The default implementation for this method calls
this.log(level, (ResourceBundle)null, msg, thrown); - Parameters:
level- the log message level.msg- the string message (or a key in the message catalog, if this logger is alocalized logger); can benull.thrown- aThrowableassociated with the log message; can benull.- Throws:
NullPointerException- iflevelisnull.
-
log
Logs a lazily supplied message associated with a given throwable. If the logger is currently enabled for the given log message level then a message is logged that is the result produced by the given supplier function. Otherwise, the supplier is not operated on.
- Implementation Requirements:
- When logging is enabled for the given level, the default
implementation for this method calls
this.log(level, (ResourceBundle)null, msgSupplier.get(), thrown); - Parameters:
level- one of the log message level identifiers.msgSupplier- a supplier function that produces a message.thrown- aThrowableassociated with log message; can benull.- Throws:
NullPointerException- iflevelisnull, ormsgSupplierisnull.
-
log
Logs a message with an optional list of parameters.
- Implementation Requirements:
- The default implementation for this method calls
this.log(level, (ResourceBundle)null, format, params); - Parameters:
level- one of the log message level identifiers.format- the string message format inMessageFormatformat, (or a key in the message catalog, if this logger is alocalized logger); can benull.params- an optional list of parameters to the message (may be none).- Throws:
NullPointerException- iflevelisnull.
-
log
Logs a localized message associated with a given throwable. If the given resource bundle is non-
null, themsgstring is localized using the given resource bundle. Otherwise themsgstring is not localized.- Parameters:
level- the log message level.bundle- a resource bundle to localizemsg; can benull.msg- the string message (or a key in the message catalog, ifbundleis notnull); can benull.thrown- aThrowableassociated with the log message; can benull.- Throws:
NullPointerException- iflevelisnull.
-
log
Logs a message with resource bundle and an optional list of parameters. If the given resource bundle is non-
null, theformatstring is localized using the given resource bundle. Otherwise theformatstring is not localized.- Parameters:
level- the log message level.bundle- a resource bundle to localizeformat; can benull.format- the string message format inMessageFormatformat, (or a key in the message catalog ifbundleis notnull); can benull.params- an optional list of parameters to the message (may be none).- Throws:
NullPointerException- iflevelisnull.
-
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2019, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.