|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.scooterframework.common.logging.LogUtil
public class LogUtil
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 |
|---|
public static final int TRACE
public static final int DEBUG
public static final int INFO
public static final int WARN
public static final int ERROR
public static final int FATAL
public static java.lang.String m_consoleDebug
public static int m_debugLevel
| Method Detail |
|---|
public static LogUtil getLogger(java.lang.String instanceName)
instanceName - The instance to log
public static void enableLogger()
public static void disableLogger()
public static void manualStopOn()
enableLogger() method.
public static void manualStopOff()
manualStopOn()
method for more details.
public boolean isLogLevelGreaterThanInfo()
public void trace(java.lang.Object message)
public void trace(java.lang.Object message,
java.lang.Throwable throwable)
public void debug(java.lang.Object message)
public void debug(java.lang.Object message,
java.lang.Throwable throwable)
public void info(java.lang.Object message)
public void info(java.lang.Object message,
java.lang.Throwable throwable)
public void warn(java.lang.Object message)
public void warn(java.lang.Object message,
java.lang.Throwable throwable)
public void error(java.lang.Object message)
public void error(java.lang.Object message,
java.lang.Throwable throwable)
public void fatal(java.lang.Object message)
public void fatal(java.lang.Object message,
java.lang.Throwable throwable)
public boolean isTraceEnabled()
public boolean isDebugEnabled()
public boolean isInfoEnabled()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||