Class Logger
- Direct Known Subclasses:
FallbackPassthroughLogger
- Since:
- 4.0
-
Field Summary
Fields inherited from class java.util.logging.Logger
global, GLOBAL_LOGGER_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidLogs the given message using the config level.voidLogs the given message using the fine level.voidLogs the given message using the finer level.voidLogs the given message using the finest level.abstract voidForce logs the given record by directly flushing it to the underlying handlers.voidLogs the given message using the info level.voidlog(@NonNull Level level, @NonNull String message, @Nullable Throwable th, Object @NonNull ... params) Logs the given message using the provided level.abstract @Nullable LogRecordDispatcherGet the log record dispatcher used by this logger.abstract voidlogRecordDispatcher(@Nullable LogRecordDispatcher dispatcher) Sets the log record dispatcher.voidLogs the given message using the severe level.voidLogs the given message using the warning level.Methods inherited from class java.util.logging.Logger
addHandler, config, config, entering, entering, entering, exiting, exiting, fine, fine, finer, finer, finest, finest, getAnonymousLogger, getAnonymousLogger, getFilter, getGlobal, getHandlers, getLevel, getLogger, getLogger, getName, getParent, getResourceBundle, getResourceBundleName, getUseParentHandlers, info, info, isLoggable, log, log, log, log, log, log, log, logp, logp, logp, logp, logp, logp, logrb, logrb, logrb, logrb, logrb, logrb, logrb, logrb, removeHandler, setFilter, setLevel, setParent, setResourceBundle, setUseParentHandlers, severe, severe, throwing, warning, warning
-
Constructor Details
-
Logger
Constructs a new logger instance.- Parameters:
name- the name of the logger, null for anonymous loggers.resourceBundleName- the resource bundle name used for localizing messages passed to the logger, can be null.- Throws:
MissingResourceException- if the resource bundle is given but no such bundle was found.
-
-
Method Details
-
forceLog
Force logs the given record by directly flushing it to the underlying handlers. All other log methods will try to pass the messages to the log record dispatcher first which processes them delayed.- Parameters:
logRecord- the record to log instantly.- Throws:
NullPointerException- if the given record is null.
-
logRecordDispatcher
Get the log record dispatcher used by this logger. This method returns null if no dispatcher is set, meaning that all log records which are created by this logger will be written to all handlers directly. If a dispatcher is present all records will be posted to the dispatcher which is responsible to process and post them to all registered handlers.- Returns:
- the log record dispatcher used by this logger, null if no dispatcher is set.
-
logRecordDispatcher
Sets the log record dispatcher. If the given dispatcher is null all log records will be passed to the registered handlers directly, if the dispatcher is given it will be responsible to process the given records and pass them to all registered handlers.- Parameters:
dispatcher- the new dispatcher to use, null to remove the current log dispatcher.
-
fine
public void fine(@NonNull @NonNull String message, @Nullable @Nullable Throwable throwable, Object @NonNull ... params) Logs the given message using the fine level. This method has no effect if the fine level is not enabled for this logger and will not try to format the given message.The message passed to this method must be in a valid formatter format to be formatted. If no arguments are given the message will just get printed out as-is.
This method call is equivalent to
logger.log(Level.FINE, message, throwable, params).- Parameters:
message- the message to print and format if parameters are given.throwable- the throwable associated with the current log event, can be null.params- the params to format the given message with.- Throws:
NullPointerException- if the given message or an element of the given params array is null.IllegalFormatException- if parameters are present but the given message uses an illegal format.
-
finer
public void finer(@NonNull @NonNull String message, @Nullable @Nullable Throwable throwable, Object @NonNull ... params) Logs the given message using the finer level. This method has no effect if the fine level is not enabled for this logger and will not try to format the given message.The message passed to this method must be in a valid formatter format to be formatted. If no arguments are given the message will just get printed out as-is.
This method call is equivalent to
logger.log(Level.FINER, message, throwable, params).- Parameters:
message- the message to print and format if parameters are given.throwable- the throwable associated with the current log event, can be null.params- the params to format the given message with.- Throws:
NullPointerException- if the given message or an element of the given params array is null.IllegalFormatException- if parameters are present but the given message uses an illegal format.
-
finest
public void finest(@NonNull @NonNull String message, @Nullable @Nullable Throwable throwable, Object @NonNull ... params) Logs the given message using the finest level. This method has no effect if the fine level is not enabled for this logger and will not try to format the given message.The message passed to this method must be in a valid formatter format to be formatted. If no arguments are given the message will just get printed out as-is.
This method call is equivalent to
logger.log(Level.FINEST, message, throwable, params).- Parameters:
message- the message to print and format if parameters are given.throwable- the throwable associated with the current log event, can be null.params- the params to format the given message with.- Throws:
NullPointerException- if the given message or an element of the given params array is null.IllegalFormatException- if parameters are present but the given message uses an illegal format.
-
severe
public void severe(@NonNull @NonNull String message, @Nullable @Nullable Throwable throwable, Object @NonNull ... params) Logs the given message using the severe level. This method has no effect if the fine level is not enabled for this logger and will not try to format the given message.The message passed to this method must be in a valid formatter format to be formatted. If no arguments are given the message will just get printed out as-is.
This method call is equivalent to
logger.log(Level.SEVERE, message, throwable, params).- Parameters:
message- the message to print and format if parameters are given.throwable- the throwable associated with the current log event, can be null.params- the params to format the given message with.- Throws:
NullPointerException- if the given message or an element of the given params array is null.IllegalFormatException- if parameters are present but the given message uses an illegal format.
-
warning
public void warning(@NonNull @NonNull String message, @Nullable @Nullable Throwable throwable, Object @NonNull ... params) Logs the given message using the warning level. This method has no effect if the fine level is not enabled for this logger and will not try to format the given message.The message passed to this method must be in a valid formatter format to be formatted. If no arguments are given the message will just get printed out as-is.
This method call is equivalent to
logger.log(Level.WARNING, message, throwable, params).- Parameters:
message- the message to print and format if parameters are given.throwable- the throwable associated with the current log event, can be null.params- the params to format the given message with.- Throws:
NullPointerException- if the given message or an element of the given params array is null.IllegalFormatException- if parameters are present but the given message uses an illegal format.
-
info
public void info(@NonNull @NonNull String message, @Nullable @Nullable Throwable throwable, Object @NonNull ... params) Logs the given message using the info level. This method has no effect if the fine level is not enabled for this logger and will not try to format the given message.The message passed to this method must be in a valid formatter format to be formatted. If no arguments are given the message will just get printed out as-is.
This method call is equivalent to
logger.log(Level.INFO, message, throwable, params).- Parameters:
message- the message to print and format if parameters are given.throwable- the throwable associated with the current log event, can be null.params- the params to format the given message with.- Throws:
NullPointerException- if the given message or an element of the given params array is null.IllegalFormatException- if parameters are present but the given message uses an illegal format.
-
config
public void config(@NonNull @NonNull String message, @Nullable @Nullable Throwable throwable, Object @NonNull ... params) Logs the given message using the config level. This method has no effect if the fine level is not enabled for this logger and will not try to format the given message.The message passed to this method must be in a valid formatter format to be formatted. If no arguments are given the message will just get printed out as-is.
This method call is equivalent to
logger.log(Level.CONFIG, message, throwable, params).- Parameters:
message- the message to print and format if parameters are given.throwable- the throwable associated with the current log event, can be null.params- the params to format the given message with.- Throws:
NullPointerException- if the given message or an element of the given params array is null.IllegalFormatException- if parameters are present but the given message uses an illegal format.
-
log
public void log(@NonNull @NonNull Level level, @NonNull @NonNull String message, @Nullable @Nullable Throwable th, Object @NonNull ... params) Logs the given message using the provided level. This method has no effect if the fine level is not enabled for this logger and will not try to format the given message.The message passed to this method must be in a valid formatter format to be formatted. If no arguments are given the message will just get printed out as-is.
- Parameters:
level- the level of the log record to log.message- the message to print and format if parameters are given.th- the throwable associated with the current log event, can be null.params- the params to format the given message with.- Throws:
NullPointerException- if the given level, message or an element of the params array is null.IllegalFormatException- if parameters are present but the given message uses an illegal format.
-