Top Description Fields Constructors Methods
com.sun.istack.logging

public Class Logger

extends Object
Class Inheritance
Imports
com.sun.istack.NotNull, java.util.StringTokenizer, java.util.logging.Level

This is a helper class that provides some convenience methods wrapped around the standard java.util.logging.Logger interface. The class also makes sure that logger names of each Metro subsystem are consistent with each other.
Authors
Marek Potociar, Fabian Ritzmann

Field Summary

Modifier and TypeField and Description
private final String
private final Logger
private static final Level
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
protected
Logger(final String
system logger name
systemLoggerName
,
final String
component name
componentName
)

Prevents creation of a new instance of this Logger unless used by a subclass.

Method Summary

Modifier and TypeMethod and Description
public void
config(final String message)

public void
config(final String message, Object[] params)

public void
config(final String message, final Throwable thrown)

public void
public void
entering(final Object... parameters)

public void
public void
exiting(final Object result)

public void
fine(final String message)

public void
fine(final String message, final Throwable thrown)

public void
finer(final String message)

public void
finer(final String message, Object[] params)

public void
finer(final String message, final Throwable thrown)

public void
finest(final String message)

public void
finest(final String message, Object[] params)

public void
finest(final String message, final Throwable thrown)

public static Logger

Returns:

logger instance preconfigured for use with the component
getLogger
(final Class<?>
class of the component that will use the logger instance. Must not be null.
componentClass
)

The factory method returns preconfigured Logger wrapper for the class.

public static Logger

Returns:

logger instance preconfigured for use with the component
getLogger
(final String
custom name of the logger.
customLoggerName
,
final Class<?>
class of the component that will use the logger instance. Must not be null.
componentClass
)

The factory method returns preconfigured Logger wrapper for the class.

pack-priv static final String

Returns:

system logger name for the given componentClass instance
getSystemLoggerName
(Class<?>
class of the component that will use the logger instance. Must not be null.
componentClass
)

Calculates the subsystem suffix based on the package of the component class

public void
info(final String message)

public void
info(final String message, Object[] params)

public void
info(final String message, final Throwable thrown)

public boolean
isLoggable(final Level level)

public boolean
public void
log(final Level level, final String message)

public void
log(final Level level, final String message, Object param1)

public void
log(final Level level, final String message, Object[] params)

public void
log(final Level level, final String message, final Throwable thrown)

public <
type
T extends Throwable
>
T

Returns:

the same exception instance that was passed in as the exception parameter.
logException
(final T
exception whose message should be logged. Must not be null.
exception
,
final Throwable
initial cause of the exception that should be logged as well and set as exception's original cause. May be null.
cause
,
final Level
loging level which should be used for logging
level
)

Method logs exception's message at the logging level specified by the level argument.

public <
type
T extends Throwable
>
T

Returns:

the same exception instance that was passed in as the exception parameter.
logException
(final T
exception whose message should be logged. Must not be null.
exception
,
final boolean
deterimnes whether initial cause of the exception should be logged as well
logCause
,
final Level
loging level which should be used for logging
level
)

Method logs exception's message at the logging level specified by the level argument.

public <
type
T extends Throwable
>
T

Returns:

the same exception instance that was passed in as the exception parameter.
logException
(final T
exception whose message should be logged. Must not be null.
exception
,
final Level
loging level which should be used for logging
level
)

Same as logException(exception, true, level).

public <
type
T extends Throwable
>
T

Returns:

the same exception instance that was passed in as the exception parameter.
logSevereException
(final T
exception whose message should be logged. Must not be null.
exception
,
final Throwable
initial cause of the exception that should be logged as well and set as exception's original cause. May be null.
cause
)

Method logs exception's message as a SEVERE logging level message.

public <
type
T extends Throwable
>
T

Returns:

the same exception instance that was passed in as the exception parameter.
logSevereException
(final T
exception whose message should be logged. Must not be null.
exception
,
final boolean
deterimnes whether initial cause of the exception should be logged as well
logCause
)

Method logs exception's message as a SEVERE logging level message.

public <
type
T extends Throwable
>
T

Returns:

the same exception instance that was passed in as the exception parameter.
logSevereException
(final T
exception whose message should be logged. Must not be null.
exception
)

Same as logSevereException(exception, true).

public void
setLevel(final Level level)

public void
severe(final String message)

public void
severe(final String message, Object[] params)

public void
severe(final String message, final Throwable thrown)

public void
warning(final String message)

public void
warning(final String message, Object[] params)

public void
warning(final String message, final Throwable thrown)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

componentClassNameback to summary
private final String componentClassName
loggerback to summary
private final Logger logger
METHOD_CALL_LEVEL_VALUEback to summary
private static final Level METHOD_CALL_LEVEL_VALUE
ROOT_WS_PACKAGEback to summary
private static final String ROOT_WS_PACKAGE
WS_LOGGING_SUBSYSTEM_NAME_ROOTback to summary
private static final String WS_LOGGING_SUBSYSTEM_NAME_ROOT

Constructor Detail

Loggerback to summary
protected Logger(final String systemLoggerName, final String componentName)

Prevents creation of a new instance of this Logger unless used by a subclass.

Parameters
systemLoggerName:String

system logger name

componentName:String

component name

Method Detail

configback to summary
public void config(final String message)
configback to summary
public void config(final String message, Object[] params)
configback to summary
public void config(final String message, final Throwable thrown)
enteringback to summary
public void entering()
enteringback to summary
public void entering(final Object... parameters)
exitingback to summary
public void exiting()
exitingback to summary
public void exiting(final Object result)
fineback to summary
public void fine(final String message)
fineback to summary
public void fine(final String message, final Throwable thrown)
finerback to summary
public void finer(final String message)
finerback to summary
public void finer(final String message, Object[] params)
finerback to summary
public void finer(final String message, final Throwable thrown)
finestback to summary
public void finest(final String message)
finestback to summary
public void finest(final String message, Object[] params)
finestback to summary
public void finest(final String message, final Throwable thrown)
getLoggerback to summary
public static Logger getLogger(final 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.

Parameters
componentClass:Class<?>

class of the component that will use the logger instance. Must not be null.

Returns:Logger

logger instance preconfigured for use with the component

Annotations
@NotNull
Exceptions
NullPointerException:
if the componentClass parameter is null.
getLoggerback to summary
public static Logger getLogger(final String customLoggerName, final 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 use getLogger(java.lang.Class) method.

Parameters
customLoggerName:String

custom name of the logger.

componentClass:Class<?>

class of the component that will use the logger instance. Must not be null.

Returns:Logger

logger instance preconfigured for use with the component

Annotations
@NotNull
Exceptions
NullPointerException:
if the componentClass parameter is null.
See Also
getLogger(java.lang.Class)
getSystemLoggerNameback to summary
pack-priv static final String getSystemLoggerName(Class<?> componentClass)

Calculates the subsystem suffix based on the package of the component class

Parameters
componentClass:Class<?>

class of the component that will use the logger instance. Must not be null.

Returns:String

system logger name for the given componentClass instance

infoback to summary
public void info(final String message)
infoback to summary
public void info(final String message, Object[] params)
infoback to summary
public void info(final String message, final Throwable thrown)
isLoggableback to summary
public boolean isLoggable(final Level level)
isMethodCallLoggableback to summary
public boolean isMethodCallLoggable()
logback to summary
public void log(final Level level, final String message)
logback to summary
public void log(final Level level, final String message, Object param1)
logback to summary
public void log(final Level level, final String message, Object[] params)
logback to summary
public void log(final Level level, final String message, final Throwable thrown)
logExceptionback to summary
public <T extends Throwable> T logException(final T exception, final Throwable cause, final Level level)

Method logs 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.

Parameters
<T>
type
exception:T

exception whose message should be logged. Must not be null.

cause:Throwable

initial cause of the exception that should be logged as well and set as exception's original cause. May be null.

level:Level

loging level which should be used for logging

Returns:T

the same exception instance that was passed in as the exception parameter.

logExceptionback to summary
public <T extends Throwable> T logException(final T exception, final boolean logCause, final Level level)

Method logs 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.

Parameters
<T>
type
exception:T

exception whose message should be logged. Must not be null.

logCause:boolean

deterimnes whether initial cause of the exception should be logged as well

level:Level

loging level which should be used for logging

Returns:T

the same exception instance that was passed in as the exception parameter.

logExceptionback to summary
public <T extends Throwable> T logException(final T exception, final Level level)

Same as logException(exception, true, level).

Parameters
<T>
type
exception:T

exception whose message should be logged. Must not be null.

level:Level

loging level which should be used for logging

Returns:T

the same exception instance that was passed in as the exception parameter.

logSevereExceptionback to summary
public <T extends Throwable> T logSevereException(final T exception, final Throwable cause)

Method logs 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.

Parameters
<T>
type
exception:T

exception whose message should be logged. Must not be null.

cause:Throwable

initial cause of the exception that should be logged as well and set as exception's original cause. May be null.

Returns:T

the same exception instance that was passed in as the exception parameter.

logSevereExceptionback to summary
public <T extends Throwable> T logSevereException(final T exception, final boolean logCause)

Method logs 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.

Parameters
<T>
type
exception:T

exception whose message should be logged. Must not be null.

logCause:boolean

deterimnes whether initial cause of the exception should be logged as well

Returns:T

the same exception instance that was passed in as the exception parameter.

logSevereExceptionback to summary
public <T extends Throwable> T logSevereException(final T exception)

Same as logSevereException(exception, true).

Parameters
<T>
type
exception:T

exception whose message should be logged. Must not be null.

Returns:T

the same exception instance that was passed in as the exception parameter.

setLevelback to summary
public void setLevel(final Level level)
severeback to summary
public void severe(final String message)
severeback to summary
public void severe(final String message, Object[] params)
severeback to summary
public void severe(final String message, final Throwable thrown)
warningback to summary
public void warning(final String message)
warningback to summary
public void warning(final String message, Object[] params)
warningback to summary
public void warning(final String message, final Throwable thrown)