com.scooterframework.common.logging
Class LogUtil

java.lang.Object
  extended by com.scooterframework.common.logging.LogUtil

public class LogUtil
extends java.lang.Object

LogUtil class. This class uses Apache's Log4J as logger. Configuration information can be found in log4j.properties. You may also create your own log4j properties file. If your application shares the same container with other applications, be careful on the log file name you choose.

 Usage:
    1. In your application class, declare the following
        LogUtil log = LogUtil.getLogger(this.getClass().getName());

    2. Then you can log message with this code:
        log.debug(message);

        or better with these codes:
        if (log.isDebugEnabled()) {
            log.debug(message);
        }

     3. Modify log4j.properties file according to your own application:
        This may be necessary if you want log file names do not conflict with
        other application's log file names in the same container.

     4. Use your own myApp_log4j.properties file: This is optional.
        4.1 Create a file named myApp_log4j.properties
        4.2 Make sure this file is on your classpath.
        4.3 Add this system property on your container start line:
            -Dlog4j.configuration=myApp_log4j.properties
 


Field Summary
static int DEBUG
           
static int ERROR
           
static int FATAL
           
static int INFO
           
static java.lang.String m_consoleDebug
           
static int m_debugLevel
           
static int TRACE
           
static int WARN
           
 
Method Summary
 void debug(java.lang.Object message)
          Method to log a debug message
 void debug(java.lang.Object message, java.lang.Throwable throwable)
          Method to log a debug message
static void disableLogger()
          Disables the logger.
static void enableLogger()
          Enables the logger.
 void error(java.lang.Object message)
          Method to log an error message
 void error(java.lang.Object message, java.lang.Throwable throwable)
          Method to log an error message
 void fatal(java.lang.Object message)
          Method to log a fatal message
 void fatal(java.lang.Object message, java.lang.Throwable throwable)
          Method to log a fatal message
static LogUtil getLogger(java.lang.String instanceName)
          Starts a Logger for a specific instance.
 void info(java.lang.Object message)
          Method to log an info message
 void info(java.lang.Object message, java.lang.Throwable throwable)
          Method to log an info message
 boolean isDebugEnabled()
          Check whether this category is enabled for the DEBUG Level.
 boolean isInfoEnabled()
          Check whether this category is enabled for the INFO Level.
 boolean isLogLevelGreaterThanInfo()
           
 boolean isTraceEnabled()
          Check whether this category is enabled for the TRACE Level.
static void manualStopOff()
          Removes a stop on the logger.
static void manualStopOn()
          Puts a stop on the logger.
 void trace(java.lang.Object message)
          Method to log a trace message
 void trace(java.lang.Object message, java.lang.Throwable throwable)
          Method to log a trace message
 void warn(java.lang.Object message)
          Method to log a warning message
 void warn(java.lang.Object message, java.lang.Throwable throwable)
          Method to log a warning message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE

public static final int TRACE
See Also:
Constant Field Values

DEBUG

public static final int DEBUG
See Also:
Constant Field Values

INFO

public static final int INFO
See Also:
Constant Field Values

WARN

public static final int WARN
See Also:
Constant Field Values

ERROR

public static final int ERROR
See Also:
Constant Field Values

FATAL

public static final int FATAL
See Also:
Constant Field Values

m_consoleDebug

public static java.lang.String m_consoleDebug

m_debugLevel

public static int m_debugLevel
Method Detail

getLogger

public static LogUtil getLogger(java.lang.String instanceName)
Starts a Logger for a specific instance.

Parameters:
instanceName - The instance to log
Returns:
this instance

enableLogger

public static void enableLogger()
Enables the logger.


disableLogger

public static void disableLogger()
Disables the logger.


manualStopOn

public static void manualStopOn()
Puts a stop on the logger. Sometimes logger is enabled by other program. Use this method if you want to nullify any calls to the enableLogger() method.


manualStopOff

public static void manualStopOff()
Removes a stop on the logger. See description of manualStopOn() method for more details.


isLogLevelGreaterThanInfo

public boolean isLogLevelGreaterThanInfo()

trace

public void trace(java.lang.Object message)
Method to log a trace message


trace

public void trace(java.lang.Object message,
                  java.lang.Throwable throwable)
Method to log a trace message


debug

public void debug(java.lang.Object message)
Method to log a debug message


debug

public void debug(java.lang.Object message,
                  java.lang.Throwable throwable)
Method to log a debug message


info

public void info(java.lang.Object message)
Method to log an info message


info

public void info(java.lang.Object message,
                 java.lang.Throwable throwable)
Method to log an info message


warn

public void warn(java.lang.Object message)
Method to log a warning message


warn

public void warn(java.lang.Object message,
                 java.lang.Throwable throwable)
Method to log a warning message


error

public void error(java.lang.Object message)
Method to log an error message


error

public void error(java.lang.Object message,
                  java.lang.Throwable throwable)
Method to log an error message


fatal

public void fatal(java.lang.Object message)
Method to log a fatal message


fatal

public void fatal(java.lang.Object message,
                  java.lang.Throwable throwable)
Method to log a fatal message


isTraceEnabled

public boolean isTraceEnabled()
Check whether this category is enabled for the TRACE Level.

Returns:
boolean - true if this category is enabled for level TRACE, false otherwise.

isDebugEnabled

public boolean isDebugEnabled()
Check whether this category is enabled for the DEBUG Level.

Returns:
boolean - true if this category is enabled for level DEBUG, false otherwise.

isInfoEnabled

public boolean isInfoEnabled()
Check whether this category is enabled for the INFO Level.

Returns:
boolean - true if this category is enabled for level INFO, false otherwise.