istack common utility code 2.6.1-redhat-2

com.sun.istack.logging
Class Logger

java.lang.Object
  extended by com.sun.istack.logging.Logger

public class Logger
extends Object

This is a helper class that provides some conveniece methods wrapped around the standard 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
protected Logger(String systemLoggerName, String componentName)
          Prevents creation of a new instance of this Logger unless used by a subclass.
 
Method Summary
 void config(String message)
           
 void config(String message, Throwable thrown)
           
 void entering()
           
 void entering(Object... parameters)
           
 void exiting()
           
 void exiting(Object result)
           
 void fine(String message)
           
 void fine(String message, Throwable thrown)
           
 void finer(String message)
           
 void finer(String message, Throwable thrown)
           
 void finest(String message)
           
 void finest(String message, Throwable thrown)
           
static Logger getLogger(Class<?> componentClass)
           The factory method returns preconfigured Logger wrapper for the class.
static Logger getLogger(String customLoggerName, Class<?> componentClass)
          The factory method returns preconfigured Logger wrapper for the class.
 void info(String message)
           
 void info(String message, Throwable thrown)
           
 boolean isLoggable(Level level)
           
 boolean isMethodCallLoggable()
           
 void log(Level level, String message)
           
 void log(Level level, String message, Throwable thrown)
           
<T extends Throwable>
T
logException(T exception, boolean logCause, Level level)
          Method logs exception's message at the logging level specified by the level argument.
<T extends Throwable>
T
logException(T exception, Level level)
          Same as logException(exception, true, level).
<T extends Throwable>
T
logException(T exception, Throwable cause, Level level)
          Method logs exception's message at the logging level specified by the level argument.
<T extends Throwable>
T
logSevereException(T exception)
          Same as logSevereException(exception, true).
<T extends Throwable>
T
logSevereException(T exception, boolean logCause)
          Method logs exception's message as a SEVERE logging level message.
<T extends Throwable>
T
logSevereException(T exception, Throwable cause)
          Method logs exception's message as a SEVERE logging level message.
 void setLevel(Level level)
           
 void severe(String message)
           
 void severe(String message, Throwable thrown)
           
 void warning(String message)
           
 void warning(String message, Throwable thrown)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Logger

protected Logger(String systemLoggerName,
                 String componentName)
Prevents creation of a new instance of this Logger unless used by a subclass.

Method Detail

getLogger

@NotNull
public static Logger getLogger(@NotNull
                                       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 of the component that will use the logger instance. Must not be null.
Returns:
logger instance preconfigured for use with the component
Throws:
NullPointerException - if the componentClass parameter is null.

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 use getLogger(java.lang.Class) method.

Parameters:
customLoggerName - custom name of the logger.
componentClass - class of the component that will use the logger instance. Must not be null.
Returns:
logger instance preconfigured for use with the component
Throws:
NullPointerException - if the componentClass parameter is null.
See Also:
getLogger(java.lang.Class)

log

public void log(Level level,
                String message)

log

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

finest

public void finest(String message)

finest

public void finest(String message,
                   Throwable thrown)

finer

public void finer(String message)

finer

public void finer(String message,
                  Throwable thrown)

fine

public void fine(String message)

fine

public void fine(String message,
                 Throwable thrown)

info

public void info(String message)

info

public void info(String message,
                 Throwable thrown)

config

public void config(String message)

config

public void config(String message,
                   Throwable thrown)

warning

public void warning(String message)

warning

public void warning(String message,
                    Throwable thrown)

severe

public void severe(String message)

severe

public void severe(String message,
                   Throwable thrown)

isMethodCallLoggable

public boolean isMethodCallLoggable()

isLoggable

public boolean isLoggable(Level level)

setLevel

public void setLevel(Level level)

entering

public void entering()

entering

public void entering(Object... parameters)

exiting

public void exiting()

exiting

public void exiting(Object result)

logSevereException

public <T extends Throwable> T logSevereException(T exception,
                                                  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:
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.
Returns:
the same exception instance that was passed in as the exception parameter.

logSevereException

public <T extends Throwable> T logSevereException(T exception,
                                                  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:
exception - exception whose message should be logged. Must not be null.
logCause - deterimnes whether initial cause of the exception should be logged as well
Returns:
the same exception instance that was passed in as the exception parameter.

logSevereException

public <T extends Throwable> T logSevereException(T exception)
Same as logSevereException(exception, true).


logException

public <T extends Throwable> T logException(T exception,
                                            Throwable cause,
                                            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:
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 logging
Returns:
the same exception instance that was passed in as the exception parameter.

logException

public <T extends Throwable> T logException(T exception,
                                            boolean logCause,
                                            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:
exception - exception whose message should be logged. Must not be null.
logCause - deterimnes whether initial cause of the exception should be logged as well
level - loging level which should be used for logging
Returns:
the same exception instance that was passed in as the exception parameter.

logException

public <T extends Throwable> T logException(T exception,
                                            Level level)
Same as logException(exception, true, level).


istack common utility code 2.6.1-redhat-2

Copyright © 2012 JBoss by Red Hat. All Rights Reserved.