| org.cougaar.util.log.Logger
All known Subclasses: org.cougaar.util.log.LoggerAdapter,
Logger | public interface Logger (Code) | | The Logger provides a generic logging API.
This provides the basic:
if (log.isDebugEnabled()) {
log.debug("my message");
}
and related logging methods.
This API is a subset of the "log4j" API, but the underlying
implementation may use a different logger, such as "jsr47".
Note that (currently) the Logger user is unable to alter the
underlying logger's threshold level. A separate
LoggerController must be used to make such modifications.
An enhancement idea is to allow a Logger user to alter this
level -- for example, this could be used to increase logging
detail when an error is deteted. For now the equivalent
behavior can be obtained by using "log(level, ..)" and
selecting the "level" value at runtime.
|
Field Summary | |
int | DEBUG | int | DETAIL Generic logging levels.
The value of these constants may be modified in the future
without notice. | int | ERROR | int | FATAL | int | INFO | int | SHOUT | int | WARN |
Method Summary | |
void | debug(String message) Equivalent to "log(DEBUG, ..)". | void | debug(String message, Throwable t) | void | detail(String message) Equivalent to "log(DETAIL, ..)". | void | detail(String message, Throwable t) | void | error(String message) Equivalent to "log(ERROR, ..)". | void | error(String message, Throwable t) | void | fatal(String message) Equivalent to "log(FATAL, ..)". | void | fatal(String message, Throwable t) | void | info(String message) Equivalent to "log(INFO, ..)". | void | info(String message, Throwable t) | boolean | isDebugEnabled() | boolean | isDetailEnabled() | boolean | isEnabledFor(int level) Logger users should check "isEnabledFor(..)" before requesting
a log message, to prevent unnecessary string creation.
When the log message requires constructing a String (e.g.
by using "+", or by calculating some value), then the
"is*Enabled(..)" check is preferred. | boolean | isErrorEnabled() | boolean | isFatalEnabled() | boolean | isInfoEnabled() | boolean | isShoutEnabled() | boolean | isWarnEnabled() | void | log(int level, String message) Append the specified message to the log, but only if the
logger includes the specified logging level. | void | log(int level, String message, Throwable t) Append both specified message and throwable to the log, but
only if the logger includes the specified logging level.
If the throwable is null then this is equivalent to:
log(level, message).
Parameters: level - the required logging level (DEBUG, WARN, etc) Parameters: message - the string to log Parameters: t - the throwable (e.g. | void | printDot(String dot) | void | shout(String message) Equivalent to "log(SHOUT, ..)". | void | shout(String message, Throwable t) | void | warn(String message) Equivalent to "log(WARN, ..)". | void | warn(String message, Throwable t) |
DETAIL | int DETAIL(Code) | | Generic logging levels.
The value of these constants may be modified in the future
without notice. For example, "DEBUG" may be changed from
"1" to some other integer constant. However, the ordering
of:
DETAIL < DEBUG < INFO < WARN < ERROR < SHOUT < FATAL
is guaranteed.
|
debug | void debug(String message)(Code) | | Equivalent to "log(DEBUG, ..)".
|
detail | void detail(String message)(Code) | | Equivalent to "log(DETAIL, ..)".
|
error | void error(String message)(Code) | | Equivalent to "log(ERROR, ..)".
|
fatal | void fatal(String message)(Code) | | Equivalent to "log(FATAL, ..)".
|
info | void info(String message)(Code) | | Equivalent to "log(INFO, ..)".
|
isDebugEnabled | boolean isDebugEnabled()(Code) | | |
isDetailEnabled | boolean isDetailEnabled()(Code) | | |
isEnabledFor | boolean isEnabledFor(int level)(Code) | | Logger users should check "isEnabledFor(..)" before requesting
a log message, to prevent unnecessary string creation.
When the log message requires constructing a String (e.g.
by using "+", or by calculating some value), then the
"is*Enabled(..)" check is preferred. For example:
if (isDebugEnabled()) {
debug("good, this message will be logged, "+someArg);
}
is prefered to:
debug("maybe this will be logged, maybe wasteful, "+someArg);
The one exception is when the message is a constant string,
in which case the "is*Enabled(..)" check is unnecessary.
For example:
debug("a constant string is okay");
is just as good as:
if (isDebugEnabled()) {
debug("isDebug check not needed, but harmless");
}
However, developers often modify their logging statements,
so it's best to always use the "is*Enabled(..)" pattern.
Although this seems like a minor point, these string allocations
can add up to a potentially large (and needless) performance
penalty when the logging level is turned down.
Parameters: level - a logging level, such as DEBUG |
isErrorEnabled | boolean isErrorEnabled()(Code) | | |
isFatalEnabled | boolean isFatalEnabled()(Code) | | |
isInfoEnabled | boolean isInfoEnabled()(Code) | | |
isShoutEnabled | boolean isShoutEnabled()(Code) | | |
isWarnEnabled | boolean isWarnEnabled()(Code) | | |
log | void log(int level, String message)(Code) | | Append the specified message to the log, but only if the
logger includes the specified logging level.
Parameters: level - the required logging level (DEBUG, WARN, etc) Parameters: message - the string to log See Also: Logger.isEnabledFor(int) |
log | void log(int level, String message, Throwable t)(Code) | | Append both specified message and throwable to the log, but
only if the logger includes the specified logging level.
If the throwable is null then this is equivalent to:
log(level, message).
Parameters: level - the required logging level (DEBUG, WARN, etc) Parameters: message - the string to log Parameters: t - the throwable (e.g. RuntimeException) that is related to the message See Also: Logger.isEnabledFor(int) |
shout | void shout(String message)(Code) | | Equivalent to "log(SHOUT, ..)".
|
warn | void warn(String message)(Code) | | Equivalent to "log(WARN, ..)".
|
|
|