Class Logger
- Direct Known Subclasses:
PolicyLogger
Logger interface.
The class also makes sure that logger names of each Metro subsystem are consistent
with each other.- Author:
- Marek Potociar, Fabian Ritzmann
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidentering()voidvoidexiting()voidvoidvoidvoidvoidvoidvoidvoidvoidstatic LoggerThe factory method returns preconfigured Logger wrapper for the class.static LoggerThe factory method returns preconfigured Logger wrapper for the class.voidvoidvoidbooleanisLoggable(Level level) booleanvoidvoidvoidvoid<T extends Throwable>
TlogException(T exception, boolean logCause, Level level) Method logsexception's message at the logging level specified by thelevelargument.<T extends Throwable>
TlogException(T exception, Throwable cause, Level level) Method logsexception's message at the logging level specified by thelevelargument.<T extends Throwable>
TlogException(T exception, Level level) Same aslogException(exception, true, level).<T extends Throwable>
TlogSevereException(T exception) Same aslogSevereException(exception, true).<T extends Throwable>
TlogSevereException(T exception, boolean logCause) Method logsexception's message as aSEVERElogging level message.<T extends Throwable>
TlogSevereException(T exception, Throwable cause) Method logsexception's message as aSEVERElogging level message.voidvoidvoidvoidvoidvoidvoid
-
Constructor Details
-
Logger
Prevents creation of a new instance of this Logger unless used by a subclass.
-
-
Method Details
-
getLogger
The factory method returns preconfigured Logger wrapper for the class. Method calls
getSystemLoggerName(java.lang.Class)to generate default logger name.Since there is no caching implemented, it is advised that the method is called only once per a class in order to initialize a final static logger variable, which is then used through the class to perform actual logging tasks.
- Parameters:
componentClass- class of the component that will use the logger instance. Must not benull.- Returns:
- logger instance preconfigured for use with the component
- Throws:
NullPointerException- if the componentClass parameter isnull.
-
getLogger
@NotNull public static Logger getLogger(@NotNull String customLoggerName, @NotNull Class<?> componentClass) The factory method returns preconfigured Logger wrapper for the class. Since there is no caching implemented, it is advised that the method is called only once per a class in order to initialize a final static logger variable, which is then used through the class to perform actual logging tasks. This method should be only used in a special cases when overriding of a default logger name derived from the package of the component class is needed. For all common use cases please usegetLogger(java.lang.Class)method.- Parameters:
customLoggerName- custom name of the logger.componentClass- class of the component that will use the logger instance. Must not benull.- Returns:
- logger instance preconfigured for use with the component
- Throws:
NullPointerException- if the componentClass parameter isnull.- See Also:
-
log
-
log
-
log
-
log
-
finest
-
finest
-
finest
-
finer
-
finer
-
finer
-
fine
-
fine
-
info
-
info
-
info
-
config
-
config
-
config
-
warning
-
warning
-
warning
-
severe
-
severe
-
severe
-
isMethodCallLoggable
public boolean isMethodCallLoggable() -
isLoggable
-
setLevel
-
entering
public void entering() -
entering
-
exiting
public void exiting() -
exiting
-
logSevereException
Method logsexception's message as aSEVERElogging level message.If
causeparameter is notnull, it is logged as well andexceptionoriginal cause is initialized with instance referenced bycauseparameter.- Parameters:
exception- exception whose message should be logged. Must not benull.cause- initial cause of the exception that should be logged as well and set asexception's original cause. May benull.- Returns:
- the same exception instance that was passed in as the
exceptionparameter.
-
logSevereException
Method logsexception's message as aSEVERElogging level message.If
logCauseparameter istrue,exception's original cause is logged as well (if exists). This may be used in cases whenexception's class provides constructor to initialize the original cause. In such case you do not need to uselogSevereException(Throwable, Throwable)method version but you might still want to log the original cause as well.- Parameters:
exception- exception whose message should be logged. Must not benull.logCause- deterimnes whether initial cause of the exception should be logged as well- Returns:
- the same exception instance that was passed in as the
exceptionparameter.
-
logSevereException
Same aslogSevereException(exception, true). -
logException
Method logsexception's message at the logging level specified by thelevelargument.If
causeparameter is notnull, it is logged as well andexceptionoriginal cause is initialized with instance referenced bycauseparameter.- Parameters:
exception- exception whose message should be logged. Must not benull.cause- initial cause of the exception that should be logged as well and set asexception's original cause. May benull.level- loging level which should be used for logging- Returns:
- the same exception instance that was passed in as the
exceptionparameter.
-
logException
Method logsexception's message at the logging level specified by thelevelargument.If
logCauseparameter istrue,exception's original cause is logged as well (if exists). This may be used in cases whenexception's class provides constructor to initialize the original cause. In such case you do not need to uselogException(exception, cause, level)method version but you might still want to log the original cause as well.- Parameters:
exception- exception whose message should be logged. Must not benull.logCause- deterimnes whether initial cause of the exception should be logged as welllevel- loging level which should be used for logging- Returns:
- the same exception instance that was passed in as the
exceptionparameter.
-
logException
Same aslogException(exception, true, level).
-