| java.lang.Object org.apache.commons.logging.impl.SimpleLog
SimpleLog | public class SimpleLog implements Log,Serializable(Code) | | Simple implementation of Log that sends all enabled log messages,
for all defined loggers, to System.err. The following system properties
are supported to configure the behavior of this logger:
org.apache.commons.logging.simplelog.defaultlog -
Default logging detail level for all instances of SimpleLog.
Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
If not specified, defaults to "info".
org.apache.commons.logging.simplelog.log.xxxxx -
Logging detail level for a SimpleLog instance named "xxxxx".
Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
If not specified, the default logging detail level is used.
org.apache.commons.logging.simplelog.showlogname -
Set to true if you want the Log instance name to be
included in output messages. Defaults to false .
org.apache.commons.logging.simplelog.showShortLogname -
Set to true if you want the last component of the name to be
included in output messages. Defaults to true .
org.apache.commons.logging.simplelog.showdatetime -
Set to true if you want the current date and time
to be included in output messages. Default is false .
org.apache.commons.logging.simplelog.dateTimeFormat -
The date and time format to be used in the output messages.
The pattern describing the date and time format is the same that is
used in java.text.SimpleDateFormat . If the format is not
specified or is invalid, the default format is used.
The default format is yyyy/MM/dd HH:mm:ss:SSS zzz .
In addition to looking for system properties with the names specified
above, this implementation also checks for a class loader resource named
"simplelog.properties" , and includes any matching definitions
from this resource (if it exists).
author: Scott Sanders author: Rod Waldhoff author: Robert Burrell Donkin version: $Id: SimpleLog.java,v 1.21 2004/06/06 20:47:56 rdonkin Exp $ |
Constructor Summary | |
public | SimpleLog(String name) Construct a simple log with given name. |
Method Summary | |
final public void | debug(Object message) | final public void | debug(Object message, Throwable t) | final public void | error(Object message) | final public void | error(Object message, Throwable t) | final public void | fatal(Object message) | final public void | fatal(Object message, Throwable t) | public int | getLevel() Get logging level. | final public void | info(Object message) | final public void | info(Object message, Throwable t) | final public boolean | isDebugEnabled() Are debug messages currently enabled?
This allows expensive operations such as String
concatenation to be avoided when the message will be ignored by the
logger. | final public boolean | isErrorEnabled() Are error messages currently enabled?
This allows expensive operations such as String
concatenation to be avoided when the message will be ignored by the
logger. | final public boolean | isFatalEnabled() Are fatal messages currently enabled?
This allows expensive operations such as String
concatenation to be avoided when the message will be ignored by the
logger. | final public boolean | isInfoEnabled() Are info messages currently enabled?
This allows expensive operations such as String
concatenation to be avoided when the message will be ignored by the
logger. | protected boolean | isLevelEnabled(int logLevel) | final public boolean | isTraceEnabled() Are trace messages currently enabled?
This allows expensive operations such as String
concatenation to be avoided when the message will be ignored by the
logger. | final public boolean | isWarnEnabled() Are warn messages currently enabled?
This allows expensive operations such as String
concatenation to be avoided when the message will be ignored by the
logger. | protected void | log(int type, Object message, Throwable t) Do the actual logging. | public void | setLevel(int currentLogLevel) Set logging level. | final public void | trace(Object message) | final public void | trace(Object message, Throwable t) | final public void | warn(Object message) | final public void | warn(Object message, Throwable t) | protected void | write(StringBuffer buffer) Write the content of the message accumulated in the specified
StringBuffer to the appropriate output destination. |
DEFAULT_DATE_TIME_FORMAT | final protected static String DEFAULT_DATE_TIME_FORMAT(Code) | | The default format to use when formating dates
|
LOG_LEVEL_ALL | final public static int LOG_LEVEL_ALL(Code) | | Enable all logging levels
|
LOG_LEVEL_DEBUG | final public static int LOG_LEVEL_DEBUG(Code) | | "Debug" level logging.
|
LOG_LEVEL_ERROR | final public static int LOG_LEVEL_ERROR(Code) | | "Error" level logging.
|
LOG_LEVEL_FATAL | final public static int LOG_LEVEL_FATAL(Code) | | "Fatal" level logging.
|
LOG_LEVEL_INFO | final public static int LOG_LEVEL_INFO(Code) | | "Info" level logging.
|
LOG_LEVEL_OFF | final public static int LOG_LEVEL_OFF(Code) | | Enable no logging levels
|
LOG_LEVEL_TRACE | final public static int LOG_LEVEL_TRACE(Code) | | "Trace" level logging.
|
LOG_LEVEL_WARN | final public static int LOG_LEVEL_WARN(Code) | | "Warn" level logging.
|
currentLogLevel | protected int currentLogLevel(Code) | | The current log level
|
dateFormatter | protected static DateFormat dateFormatter(Code) | | Used to format times
|
dateTimeFormat | protected static String dateTimeFormat(Code) | | The date and time format to use in the log message
|
logName | protected String logName(Code) | | The name of this simple log instance
|
showDateTime | protected static boolean showDateTime(Code) | | Include the current time in the log message
|
showLogName | protected static boolean showLogName(Code) | | Include the instance name in the log message?
|
showShortName | protected static boolean showShortName(Code) | | Include the short name ( last component ) of the logger in the log
message. Defaults to true - otherwise we'll be lost in a flood of
messages without knowing who sends them.
|
simpleLogProps | final protected static Properties simpleLogProps(Code) | | Properties loaded from simplelog.properties
|
systemPrefix | final protected static String systemPrefix(Code) | | All system properties used by SimpleLog start with this
|
SimpleLog | public SimpleLog(String name)(Code) | | Construct a simple log with given name.
Parameters: name - log name |
debug | final public void debug(Object message)(Code) | | Log a message with debug log level.
|
error | final public void error(Object message)(Code) | | Log a message with error log level.
|
fatal | final public void fatal(Object message)(Code) | | Log a message with fatal log level.
|
getLevel | public int getLevel()(Code) | | Get logging level.
|
info | final public void info(Object message)(Code) | | Log a message with info log level.
|
isDebugEnabled | final public boolean isDebugEnabled()(Code) | | Are debug messages currently enabled?
This allows expensive operations such as String
concatenation to be avoided when the message will be ignored by the
logger.
|
isErrorEnabled | final public boolean isErrorEnabled()(Code) | | Are error messages currently enabled?
This allows expensive operations such as String
concatenation to be avoided when the message will be ignored by the
logger.
|
isFatalEnabled | final public boolean isFatalEnabled()(Code) | | Are fatal messages currently enabled?
This allows expensive operations such as String
concatenation to be avoided when the message will be ignored by the
logger.
|
isInfoEnabled | final public boolean isInfoEnabled()(Code) | | Are info messages currently enabled?
This allows expensive operations such as String
concatenation to be avoided when the message will be ignored by the
logger.
|
isLevelEnabled | protected boolean isLevelEnabled(int logLevel)(Code) | | Is the given log level currently enabled?
Parameters: logLevel - is this level enabled? |
isTraceEnabled | final public boolean isTraceEnabled()(Code) | | Are trace messages currently enabled?
This allows expensive operations such as String
concatenation to be avoided when the message will be ignored by the
logger.
|
isWarnEnabled | final public boolean isWarnEnabled()(Code) | | Are warn messages currently enabled?
This allows expensive operations such as String
concatenation to be avoided when the message will be ignored by the
logger.
|
log | protected void log(int type, Object message, Throwable t)(Code) | | Do the actual logging.
This method assembles the message
and then calls write() to cause it to be written.
Parameters: type - One of the LOG_LEVEL_XXX constants defining the log level Parameters: message - The message itself (typically a String) Parameters: t - The exception whose stack trace should be logged |
setLevel | public void setLevel(int currentLogLevel)(Code) | | Set logging level.
Parameters: currentLogLevel - new logging level |
trace | final public void trace(Object message)(Code) | | Log a message with trace log level.
|
warn | final public void warn(Object message)(Code) | | Log a message with warn log level.
|
write | protected void write(StringBuffer buffer)(Code) | | Write the content of the message accumulated in the specified
StringBuffer to the appropriate output destination. The
default implementation writes to System.err .
Parameters: buffer - A StringBuffer containing the accumulatedtext to be logged |
|
|