public class Logger extends Category
additive, level, name, parent, repository, resourceBundle
限定符 | 构造器和说明 |
---|---|
protected |
Logger(java.lang.String name) |
限定符和类型 | 方法和说明 |
---|---|
static Logger |
getLogger(java.lang.Class clazz)
Shorthand for
getLogger(clazz.getName()) . |
static Logger |
getLogger(java.lang.String name)
Retrieve a logger named according to the value of the
name parameter. |
static Logger |
getLogger(java.lang.String name,
LoggerFactory factory)
Like
getLogger(String) except that the type of logger
instantiated depends on the type returned by the LoggerFactory.makeNewLoggerInstance(java.lang.String) method of the
factory parameter. |
static Logger |
getRootLogger()
Return the root logger for the current logger repository.
|
boolean |
isTraceEnabled()
Check whether this category is enabled for the TRACE Level.
|
void |
trace(java.lang.Object message)
Log a message object with the
TRACE level. |
void |
trace(java.lang.Object message,
java.lang.Throwable t)
Log a message object with the
TRACE level including the
stack trace of the Throwable t passed as parameter. |
addAppender, assertLog, callAppenders, debug, debug, error, error, exists, fatal, fatal, forcedLog, getAdditivity, getAllAppenders, getAppender, getChainedPriority, getCurrentCategories, getDefaultHierarchy, getEffectiveLevel, getHierarchy, getInstance, getInstance, getLevel, getLoggerRepository, getName, getParent, getPriority, getResourceBundle, getResourceBundleString, getRoot, info, info, isAttached, isDebugEnabled, isEnabledFor, isErrorEnalbed, isInfoEnabled, isWarnEnabled, l7dlog, l7dlog, log, log, log, removeAllAppenders, removeAppender, removeAppender, setAdditivity, setLevel, setPriority, setResourceBundle, shutdown, warn, warn
public static Logger getLogger(java.lang.String name)
name
parameter. If the named logger already exists,
then the existing instance will be returned. Otherwise, a new
instance is created.
By default, loggers do not have a set level but inherit it from their neareast ancestor with a set level. This is one of the central features of log4j.
name
- The name of the logger to retrieve.public static Logger getLogger(java.lang.Class clazz)
getLogger(clazz.getName())
.clazz
- The name of clazz
will be used as the
name of the logger to retrieve. See getLogger(String)
for more detailed information.public static Logger getRootLogger()
The Logger.getName()
method for the root logger always returns
string value: "root". However, calling
Logger.getLogger("root")
does not retrieve the root
logger but a logger just under root named "root".
In other words, calling this method is the only way to retrieve the root logger.
public static Logger getLogger(java.lang.String name, LoggerFactory factory)
getLogger(String)
except that the type of logger
instantiated depends on the type returned by the LoggerFactory.makeNewLoggerInstance(java.lang.String)
method of the
factory
parameter.
This method is intended to be used by sub-classes.
name
- The name of the logger to retrieve.factory
- A LoggerFactory
implementation that will
actually create a new Instance.public void trace(java.lang.Object message)
TRACE
level.message
- the message object to log.for an explanation of the logic applied.
public void trace(java.lang.Object message, java.lang.Throwable t)
TRACE
level including the
stack trace of the Throwable
t
passed as parameter.
See Category.debug(Object)
form for more detailed information.
message
- the message object to log.t
- the exception to log, including its stack trace.public boolean isTraceEnabled()
true
if this category is enabled for level
TRACE, false
otherwise.