public class Logger
extends java.lang.Object
Logger
interface.
The class also makes sure that logger names of each Metro subsystem are consistent
with each other.Modifier and Type | Field and Description |
---|---|
private java.lang.String |
componentClassName |
private java.util.logging.Logger |
logger |
private static java.util.logging.Level |
METHOD_CALL_LEVEL_VALUE |
private static java.lang.String |
ROOT_WS_PACKAGE |
private static java.lang.String |
WS_LOGGING_SUBSYSTEM_NAME_ROOT |
Modifier | Constructor and Description |
---|---|
protected |
Logger(java.lang.String systemLoggerName,
java.lang.String componentName)
Prevents creation of a new instance of this Logger unless used by a subclass.
|
Modifier and Type | Method and Description |
---|---|
void |
config(java.lang.String message) |
void |
config(java.lang.String message,
java.lang.Object[] params) |
void |
config(java.lang.String message,
java.lang.Throwable thrown) |
void |
entering() |
void |
entering(java.lang.Object... parameters) |
void |
exiting() |
void |
exiting(java.lang.Object result) |
void |
fine(java.lang.String message) |
void |
fine(java.lang.String message,
java.lang.Throwable thrown) |
void |
finer(java.lang.String message) |
void |
finer(java.lang.String message,
java.lang.Object[] params) |
void |
finer(java.lang.String message,
java.lang.Throwable thrown) |
void |
finest(java.lang.String message) |
void |
finest(java.lang.String message,
java.lang.Object[] params) |
void |
finest(java.lang.String message,
java.lang.Throwable thrown) |
private static java.lang.String |
getCallerMethodName()
Function returns the name of the caller method for the method executing this
function.
|
static Logger |
getLogger(java.lang.Class<?> componentClass)
The factory method returns preconfigured Logger wrapper for the class.
|
static Logger |
getLogger(java.lang.String customLoggerName,
java.lang.Class<?> componentClass)
The factory method returns preconfigured Logger wrapper for the class.
|
private static java.lang.String |
getStackMethodName(int methodIndexInStack)
Method returns the name of the method that is on the
methodIndexInStack
position in the call stack of the current Thread . |
(package private) static java.lang.String |
getSystemLoggerName(java.lang.Class<?> componentClass)
Calculates the subsystem suffix based on the package of the component class
|
void |
info(java.lang.String message) |
void |
info(java.lang.String message,
java.lang.Object[] params) |
void |
info(java.lang.String message,
java.lang.Throwable thrown) |
boolean |
isLoggable(java.util.logging.Level level) |
boolean |
isMethodCallLoggable() |
void |
log(java.util.logging.Level level,
java.lang.String message) |
void |
log(java.util.logging.Level level,
java.lang.String message,
java.lang.Object param1) |
void |
log(java.util.logging.Level level,
java.lang.String message,
java.lang.Object[] params) |
void |
log(java.util.logging.Level level,
java.lang.String message,
java.lang.Throwable thrown) |
<T extends java.lang.Throwable> |
logException(T exception,
boolean logCause,
java.util.logging.Level level)
Method logs
exception 's message at the logging level specified by the
level argument. |
<T extends java.lang.Throwable> |
logException(T exception,
java.util.logging.Level level)
Same as
logException(exception, true, level) . |
<T extends java.lang.Throwable> |
logException(T exception,
java.lang.Throwable cause,
java.util.logging.Level level)
Method logs
exception 's message at the logging level specified by the
level argument. |
<T extends java.lang.Throwable> |
logSevereException(T exception)
Same as
logSevereException(exception, true) . |
<T extends java.lang.Throwable> |
logSevereException(T exception,
boolean logCause)
Method logs
exception 's message as a SEVERE logging level
message. |
<T extends java.lang.Throwable> |
logSevereException(T exception,
java.lang.Throwable cause)
Method logs
exception 's message as a SEVERE logging level
message. |
void |
setLevel(java.util.logging.Level level) |
void |
severe(java.lang.String message) |
void |
severe(java.lang.String message,
java.lang.Object[] params) |
void |
severe(java.lang.String message,
java.lang.Throwable thrown) |
void |
warning(java.lang.String message) |
void |
warning(java.lang.String message,
java.lang.Object[] params) |
void |
warning(java.lang.String message,
java.lang.Throwable thrown) |
private static final java.lang.String WS_LOGGING_SUBSYSTEM_NAME_ROOT
private static final java.lang.String ROOT_WS_PACKAGE
private static final java.util.logging.Level METHOD_CALL_LEVEL_VALUE
private final java.lang.String componentClassName
private final java.util.logging.Logger logger
protected Logger(java.lang.String systemLoggerName, java.lang.String componentName)
@NotNull public static Logger getLogger(@NotNull java.lang.Class<?> componentClass)
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.
componentClass
- class of the component that will use the logger instance. Must not be null
.java.lang.NullPointerException
- if the componentClass parameter is null
.@NotNull public static Logger getLogger(@NotNull java.lang.String customLoggerName, @NotNull java.lang.Class<?> componentClass)
getLogger(java.lang.Class)
method.customLoggerName
- custom name of the logger.componentClass
- class of the component that will use the logger instance. Must not be null
.java.lang.NullPointerException
- if the componentClass parameter is null
.getLogger(java.lang.Class)
static final java.lang.String getSystemLoggerName(@NotNull java.lang.Class<?> componentClass)
componentClass
- class of the component that will use the logger instance. Must not be null
.componentClass
instancepublic void log(java.util.logging.Level level, java.lang.String message)
public void log(java.util.logging.Level level, java.lang.String message, java.lang.Object param1)
public void log(java.util.logging.Level level, java.lang.String message, java.lang.Object[] params)
public void log(java.util.logging.Level level, java.lang.String message, java.lang.Throwable thrown)
public void finest(java.lang.String message)
public void finest(java.lang.String message, java.lang.Object[] params)
public void finest(java.lang.String message, java.lang.Throwable thrown)
public void finer(java.lang.String message)
public void finer(java.lang.String message, java.lang.Object[] params)
public void finer(java.lang.String message, java.lang.Throwable thrown)
public void fine(java.lang.String message)
public void fine(java.lang.String message, java.lang.Throwable thrown)
public void info(java.lang.String message)
public void info(java.lang.String message, java.lang.Object[] params)
public void info(java.lang.String message, java.lang.Throwable thrown)
public void config(java.lang.String message)
public void config(java.lang.String message, java.lang.Object[] params)
public void config(java.lang.String message, java.lang.Throwable thrown)
public void warning(java.lang.String message)
public void warning(java.lang.String message, java.lang.Object[] params)
public void warning(java.lang.String message, java.lang.Throwable thrown)
public void severe(java.lang.String message)
public void severe(java.lang.String message, java.lang.Object[] params)
public void severe(java.lang.String message, java.lang.Throwable thrown)
public boolean isMethodCallLoggable()
public boolean isLoggable(java.util.logging.Level level)
public void setLevel(java.util.logging.Level level)
public void entering()
public void entering(java.lang.Object... parameters)
public void exiting()
public void exiting(java.lang.Object result)
public <T extends java.lang.Throwable> T logSevereException(T exception, java.lang.Throwable cause)
exception
's message as a SEVERE
logging level
message.
If cause
parameter is not null
, it is logged as well and
exception
original cause is initialized with instance referenced
by cause
parameter.exception
- exception whose message should be logged. Must not be
null
.cause
- initial cause of the exception that should be logged as well
and set as exception
's original cause. May be null
.exception
parameter.public <T extends java.lang.Throwable> T logSevereException(T exception, boolean logCause)
exception
's message as a SEVERE
logging level
message.
If logCause
parameter is true
, exception
's original
cause is logged as well (if exists). This may be used in cases when
exception
's class provides constructor to initialize the original
cause. In such case you do not need to use
logSevereException(Throwable, Throwable)
method version but you might still want to log the original cause as well.exception
- exception whose message should be logged. Must not be
null
.logCause
- deterimnes whether initial cause of the exception should
be logged as wellexception
parameter.public <T extends java.lang.Throwable> T logSevereException(T exception)
logSevereException(exception, true)
.public <T extends java.lang.Throwable> T logException(T exception, java.lang.Throwable cause, java.util.logging.Level level)
exception
's message at the logging level specified by the
level
argument.
If cause
parameter is not null
, it is logged as well and
exception
original cause is initialized with instance referenced
by cause
parameter.exception
- exception whose message should be logged. Must not be
null
.cause
- initial cause of the exception that should be logged as well
and set as exception
's original cause. May be null
.level
- loging level which should be used for loggingexception
parameter.public <T extends java.lang.Throwable> T logException(T exception, boolean logCause, java.util.logging.Level level)
exception
's message at the logging level specified by the
level
argument.
If logCause
parameter is true
, exception
's original
cause is logged as well (if exists). This may be used in cases when
exception
's class provides constructor to initialize the original
cause. In such case you do not need to use
logException(exception, cause, level)
method version but you might still want to log the original cause as well.exception
- exception whose message should be logged. Must not be
null
.logCause
- deterimnes whether initial cause of the exception should
be logged as welllevel
- loging level which should be used for loggingexception
parameter.public <T extends java.lang.Throwable> T logException(T exception, java.util.logging.Level level)
logException(exception, true, level)
.private static java.lang.String getCallerMethodName()
Thread
.private static java.lang.String getStackMethodName(int methodIndexInStack)
methodIndexInStack
position in the call stack of the current Thread
.methodIndexInStack
- index to the call stack to get the method name for.methodIndexInStack
position in the call stack of the current Thread
.