com.jfw.util
Class JFWLogger

java.lang.Object
  extended by java.util.Observable
      extended by com.jfw.util.JFWLogger
All Implemented Interfaces:
java.util.Observer

public final class JFWLogger
extends java.util.Observable
implements java.util.Observer

Used as gateway of Log4j.
Using the methods of this class for the log permits:

  1. to use the log applet JFW to see the logs remotely
  2. change the log level on demand without restart
The logger configuration is the standard one of Log4j (file log4j.xml).
All methods used for log are static and thread safe.
Is an observer of UpdateObservable. The log applet is an observer of this class (through LogViewerObserver) and is notificated every time a new log message is avalaible. To add an observer method addObserver(java.lang.Object, java.lang.String, java.lang.String) must be used.


Method Summary
 void addObserver(java.lang.Object observer, java.lang.String className, java.lang.String description)
          Add an observer.
static void debug(java.lang.String className, java.lang.String methodName, java.lang.String userId, java.lang.String componentId, java.lang.String debugMessage)
          Write a debug message.
 void deleteObserver(java.lang.Object observer, java.lang.String className)
          Remove an observer.
static void error(java.lang.String className, java.lang.String methodName, java.lang.String userId, java.lang.String componentId, java.lang.Exception e)
          Write an error message.
static void error(java.lang.String className, java.lang.String methodName, java.lang.String userId, java.lang.String componentId, java.lang.String errorMessage)
          Write an error message.
static void error(java.lang.String className, java.lang.String methodName, java.lang.String userId, java.lang.String componentId, java.lang.String errorMessage, java.lang.Exception e)
          Write an error message.
static void error(java.lang.String className, java.lang.String methodName, java.lang.String userId, java.lang.String componentId, java.lang.String errorMessage, java.lang.Throwable t)
          Write an error message.
static void error(java.lang.String className, java.lang.String methodName, java.lang.String userId, java.lang.String componentId, java.lang.Throwable t)
          Write an error message.
static JFWLogger getInstance()
          Get attribute instance.
 boolean getIsDebug()
          Get attribute IS_DEBUG.
 boolean getIsError()
          Get attribute IS_ERROR.
 boolean getIsInfo()
          Get attribute IS_INFO.
 boolean getIsProfile()
          Get attribute IS_PROFILE.
 boolean getIsWarning()
          Get attribute IS_WARNING.
static void info(java.lang.String className, java.lang.String methodName, java.lang.String userId, java.lang.String componentId, java.lang.String infoMessage)
          Write an info message.
static boolean isDebug()
          Get attribute IS_DEBUG.
static boolean isError()
          Get attribute IS_ERROR.
static boolean isInfo()
          Get attribute IS_INFO.
static boolean isProfile()
          Get attribute IS_PROFILE.
static boolean isWarning()
          Get attribute IS_WARNING.
static void profile(java.lang.String className, java.lang.String methodName, java.lang.String userId, java.lang.String componentId, long profileTime)
          Write a profiling message.
 void setIsDebug(boolean status)
          Set attribute IS_DEBUG.
 void setIsError(boolean status)
          Set attribute IS_ERROR.
 void setIsInfo(boolean status)
          Set attribute IS_INFO.
 void setIsProfile(boolean status)
          Set attribute IS_PROFILE.
 void setIsWarning(boolean status)
          Set attribute IS_WARNING.
static java.lang.String stackTrace(java.lang.Exception e)
          Get the stack trace from a Throwable object.
static java.lang.String stackTrace(java.lang.Throwable t)
          Get the stack trace from a Throwable object.
 void update(java.util.Observable observable, java.lang.Object obj)
          Observer of class UpdateObservable.
static void warning(java.lang.String className, java.lang.String methodName, java.lang.String userId, java.lang.String componentId, java.lang.String warningMessage)
          Write a warn message.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static JFWLogger getInstance()
Get attribute instance.

Returns:
attribute instance.

isDebug

public static boolean isDebug()
Get attribute IS_DEBUG.

Returns:
attribute IS_DEBUG.

isProfile

public static boolean isProfile()
Get attribute IS_PROFILE.

Returns:
attribute IS_PROFILE.

isInfo

public static boolean isInfo()
Get attribute IS_INFO.

Returns:
attribute IS_INFO.

isWarning

public static boolean isWarning()
Get attribute IS_WARNING.

Returns:
attribute IS_WARNING.

isError

public static boolean isError()
Get attribute IS_ERROR.

Returns:
attribute IS_ERROR.

error

public static void error(java.lang.String className,
                         java.lang.String methodName,
                         java.lang.String userId,
                         java.lang.String componentId,
                         java.lang.String errorMessage)
Write an error message.

Parameters:
className - the name of the class writing the log message.
methodName - the name of the method writing the log message.
userId - a user id, if any, to associated with the log message.
componentId - a component id, if any, to associated writing the log message.
errorMessage - the error message to log.

error

public static void error(java.lang.String className,
                         java.lang.String methodName,
                         java.lang.String userId,
                         java.lang.String componentId,
                         java.lang.String errorMessage,
                         java.lang.Throwable t)
Write an error message.

Parameters:
className - the name of the class writing the log message.
methodName - the name of the method writing the log message.
userId - a user id, if any, to associated with the log message.
componentId - a component id, if any, to associated writing the log message.
errorMessage - the error message to log.
t - an Throwable objest used for get the stack trace.

error

public static void error(java.lang.String className,
                         java.lang.String methodName,
                         java.lang.String userId,
                         java.lang.String componentId,
                         java.lang.Throwable t)
Write an error message.

Parameters:
className - the name of the class writing the log message.
methodName - the name of the method writing the log message.
userId - a user id, if any, to associated with the log message.
componentId - a component id, if any, to associated writing the log message.
t - an Throwable objest used for get the stack trace.

error

public static void error(java.lang.String className,
                         java.lang.String methodName,
                         java.lang.String userId,
                         java.lang.String componentId,
                         java.lang.String errorMessage,
                         java.lang.Exception e)
Write an error message.

Parameters:
className - the name of the class writing the log message.
methodName - the name of the method writing the log message.
userId - a user id, if any, to associated with the log message.
componentId - a component id, if any, to associated writing the log message.
errorMessage - the error message to log.
e - an Exception objest used for get the stack trace.

error

public static void error(java.lang.String className,
                         java.lang.String methodName,
                         java.lang.String userId,
                         java.lang.String componentId,
                         java.lang.Exception e)
Write an error message.

Parameters:
className - the name of the class writing the log message.
methodName - the name of the method writing the log message.
userId - a user id, if any, to associated with the log message.
componentId - a component id, if any, to associated writing the log message.
e - an Exception objest used for get the stack trace.

debug

public static void debug(java.lang.String className,
                         java.lang.String methodName,
                         java.lang.String userId,
                         java.lang.String componentId,
                         java.lang.String debugMessage)
Write a debug message.

Parameters:
className - the name of the class writing the log message.
methodName - the name of the method writing the log message.
userId - a user id, if any, to associated with the log message.
componentId - a component id, if any, to associated writing the log message.
debugMessage - the debug message to log.

info

public static void info(java.lang.String className,
                        java.lang.String methodName,
                        java.lang.String userId,
                        java.lang.String componentId,
                        java.lang.String infoMessage)
Write an info message.

Parameters:
className - the name of the class writing the log message.
methodName - the name of the method writing the log message.
userId - a user id, if any, to associated with the log message.
componentId - a component id, if any, to associated writing the log message.
infoMessage - the info message to log.

warning

public static void warning(java.lang.String className,
                           java.lang.String methodName,
                           java.lang.String userId,
                           java.lang.String componentId,
                           java.lang.String warningMessage)
Write a warn message.

Parameters:
className - the name of the class writing the log message.
methodName - the name of the method writing the log message.
userId - a user id, if any, to associated with the log message.
componentId - a component id, if any, to associated writing the log message.
warningMessage - the warn message to log.

profile

public static void profile(java.lang.String className,
                           java.lang.String methodName,
                           java.lang.String userId,
                           java.lang.String componentId,
                           long profileTime)
Write a profiling message. Is an info level message for Log4j.

Parameters:
className - the name of the class writing the log message.
methodName - the name of the method writing the log message.
userId - a user id, if any, to associated with the log message.
componentId - a component id, if any, to associated writing the log message.
profileTime - the profiling message to log.

stackTrace

public static java.lang.String stackTrace(java.lang.Throwable t)
Get the stack trace from a Throwable object.

Returns:
the stack trace from a Throwable object.

stackTrace

public static java.lang.String stackTrace(java.lang.Exception e)
Get the stack trace from a Throwable object.

Returns:
the stack trace from a Throwable object.

update

public void update(java.util.Observable observable,
                   java.lang.Object obj)
Observer of class UpdateObservable. Call method {#link #initialize}.

Specified by:
update in interface java.util.Observer
Parameters:
observable - the observable object.
obj - an update object.

addObserver

public void addObserver(java.lang.Object observer,
                        java.lang.String className,
                        java.lang.String description)
Add an observer. Increment attribute observers.

Parameters:
observer - an Observer instance.
className - the class name of the observer.
description - a description of the observer.

deleteObserver

public void deleteObserver(java.lang.Object observer,
                           java.lang.String className)
Remove an observer. Decrement attribute observers.

Parameters:
observer - an Observer instance.
className - the class name of the observer.

getIsDebug

public boolean getIsDebug()
Get attribute IS_DEBUG.

Returns:
attribute IS_DEBUG.

setIsDebug

public void setIsDebug(boolean status)
Set attribute IS_DEBUG.

Parameters:
status - value for IS_DEBUG.

getIsInfo

public boolean getIsInfo()
Get attribute IS_INFO.

Returns:
attribute IS_INFO.

setIsInfo

public void setIsInfo(boolean status)
Set attribute IS_INFO.

Parameters:
status - value for IS_INFO.

getIsWarning

public boolean getIsWarning()
Get attribute IS_WARNING.

Returns:
attribute IS_WARNING.

setIsWarning

public void setIsWarning(boolean status)
Set attribute IS_WARNING.

Parameters:
status - value for IS_WARNING.

getIsProfile

public boolean getIsProfile()
Get attribute IS_PROFILE.

Returns:
attribute IS_PROFILE.

setIsProfile

public void setIsProfile(boolean status)
Set attribute IS_PROFILE.

Parameters:
status - value for IS_PROFILE.

getIsError

public boolean getIsError()
Get attribute IS_ERROR.

Returns:
attribute IS_ERROR.

setIsError

public void setIsError(boolean status)
Set attribute IS_ERROR.

Parameters:
status - value for IS_ERROR.