|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.progeeks.util.log.Log
public class Log
System logging class. Allows for multiple log levels and a hierarchy of named categories. Each category can have its own log format. Example code:
public class MyTestClass { static Log log = Log.getLog( MyTestClass.class ); public void someMethod() { log.debug( "Entering someMethod()" ); log.info( "Some operation being performed." ); } }
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_CONFIG
|
static java.lang.String |
KEY_LOG_CONFIG
|
Method Summary | |
---|---|
static void |
addLogListener(LogListener listener,
java.lang.Class c,
LogLevel level)
Adds a log listener for the specified class and level. |
static void |
addLogListener(LogListener listener,
LogLevel level)
Adds a log listener to the root log category using the specified level threshold. |
static void |
addLogListener(LogListener listener,
java.lang.String category,
LogLevel level)
Adds a log listener for the specified category and level. |
static java.util.Iterator |
categoryNames()
Returns an iterator over the current log category names. |
void |
debug(java.lang.Object message)
Log a message at the debug priority level. |
void |
debug(java.lang.Object message,
java.lang.Throwable t)
Log a message at the debug priority level including the stack trace of the specified Throwable. |
static void |
end()
Threads should call this to remove the diagnostic context before exitting. |
void |
error(java.lang.Object message)
Log a message at the error priority level. |
void |
error(java.lang.Object message,
java.lang.Throwable t)
Log a message at the error priority level including the stack trace of the specified Throwable. |
static boolean |
exists(java.lang.Class c)
Returns true if the specified class already has a log target. |
static boolean |
exists(java.lang.String category)
Returns true if the specified category already has a log target. |
void |
fatal(java.lang.Object message)
Log a message at the fatal priority level. |
void |
fatal(java.lang.Object message,
java.lang.Throwable t)
Log a message at the fatal priority level including the stack trace of the specified Throwable. |
java.lang.String |
getCategoryName()
Returns the current category name for this Log instance. |
LogLevel |
getEffectiveLogLevel()
Returns the current effictive logging level of this log. |
static Log |
getLog()
Gets a log instance using the caller's class name as the category name. |
static Log |
getLog(java.lang.Class c)
Shorthand for getLog( c.getName() ); |
static Log |
getLog(java.lang.String categoryName)
Gets a log instance for writing messages of the specified category. |
LogLevel |
getLogLevel()
Returns the current logging level of this log. |
static Log |
getRootLog()
Returns the root log object. |
void |
info(java.lang.Object message)
Log a message at the info priority level. |
void |
info(java.lang.Object message,
java.lang.Throwable t)
Log a message at the info priority level including the stack trace of the specified Throwable. |
static void |
initialize()
Initializes the Logger with basic configuration. |
boolean |
isDebugEnabled()
Returns true if the current category is logging at the debug level. |
boolean |
isInfoEnabled()
Returns true if the current category is logging at the info level. |
void |
log(java.lang.Object message,
LogLevel level)
Log a message at the specified priority level. |
void |
log(java.lang.Object message,
LogLevel level,
java.lang.Throwable t)
Log a message at the specified priority level including the stack trace of the specified Throwable. |
static java.lang.String |
pop()
Clients should call this method before leaving a diagnostic context. |
static void |
push(java.lang.String context)
Pushes a new diagnostic context onto the context stack. |
void |
setLogLevel(LogLevel level)
Set the logging level of this log. |
void |
trace(java.lang.Object message)
Log a message at the trace priority level. |
void |
trace(java.lang.Object message,
java.lang.Throwable t)
Log a message at the trace priority level including the stack trace of the specified Throwable. |
void |
warn(java.lang.Object message)
Log a message at the warn priority level. |
void |
warn(java.lang.Object message,
java.lang.Throwable t)
Log a message at the warn priority level including the stack trace of the specified Throwable. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String KEY_LOG_CONFIG
public static final java.lang.String DEFAULT_CONFIG
Method Detail |
---|
public static void initialize()
public static Log getLog(java.lang.String categoryName)
categoryName
- The name of the category to which the logger will
be associated.public static Log getLog(java.lang.Class c)
c
- The class used to retrieve the category name.public static Log getLog()
public static Log getRootLog()
public static boolean exists(java.lang.String category)
public static boolean exists(java.lang.Class c)
public static java.util.Iterator categoryNames()
public static void addLogListener(LogListener listener, LogLevel level)
public static void addLogListener(LogListener listener, java.lang.String category, LogLevel level)
public static void addLogListener(LogListener listener, java.lang.Class c, LogLevel level)
public static void push(java.lang.String context)
context
- The name of the diagnostic context.public static java.lang.String pop()
public static void end()
public java.lang.String getCategoryName()
public void setLogLevel(LogLevel level)
public LogLevel getLogLevel()
public LogLevel getEffectiveLogLevel()
public void trace(java.lang.Object message)
message
- The message object to log.public void trace(java.lang.Object message, java.lang.Throwable t)
message
- The message object to log.t
- The throwable to log, including its stack trace.public void debug(java.lang.Object message)
message
- The message object to log.public void debug(java.lang.Object message, java.lang.Throwable t)
message
- The message object to log.t
- The throwable to log, including its stack trace.public void error(java.lang.Object message)
message
- The message object to log.public void error(java.lang.Object message, java.lang.Throwable t)
message
- The message object to log.t
- The throwable to log, including its stack trace.public void fatal(java.lang.Object message)
message
- The message object to log.public void fatal(java.lang.Object message, java.lang.Throwable t)
message
- The message object to log.t
- The throwable to log, including its stack trace.public void info(java.lang.Object message)
message
- The message object to log.public void info(java.lang.Object message, java.lang.Throwable t)
message
- The message object to log.t
- The throwable to log, including its stack trace.public void warn(java.lang.Object message)
message
- The message object to log.public void warn(java.lang.Object message, java.lang.Throwable t)
message
- The message object to log.t
- The throwable to log, including its stack trace.public void log(java.lang.Object message, LogLevel level)
message
- The message object to log.level
- The level at which to log the message.public void log(java.lang.Object message, LogLevel level, java.lang.Throwable t)
message
- The message object to log.level
- The level at which to log the message.t
- The throwable to log, including its stack trace.public boolean isDebugEnabled()
public boolean isInfoEnabled()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |