public class Hierarchy extends java.lang.Object implements LoggerRepository, RendererSupport, ThrowableRendererSupport
The casual user does not have to deal with this class directly.
The structure of the logger hierarchy is maintained by the
getLogger(java.lang.String)
method. The hierarchy is such that children link
to their parent but parents do not have any pointers to their
children. Moreover, loggers can be instantiated in any order, in
particular descendant before ancestor.
In case a descendant is created before a particular ancestor, then it creates a provision node for the ancestor and adds itself to the provision node. Other descendants of the same ancestor add themselves to the previously created provision node.
限定符和类型 | 方法和说明 |
---|---|
void |
addHierarchyEventListener(HierarchyEventListener listener)
Add a
HierarchyEventListener event to the repository. |
void |
addRenderer(java.lang.Class classToRender,
ObjectRenderer or)
Add an object renderer for a specific class.
|
void |
clear()
This call will clear all logger definitions from the internal
hashtable.
|
void |
emitNoAppenderWarning(Category cat) |
Logger |
exists(java.lang.String name)
Check if the named logger exists in the hierarchy.
|
void |
fireAddAppenderEvent(Category logger,
Appender appender) |
java.util.Enumeration |
getCurrentCategories()
已过时。
Please use
getCurrentLoggers() instead. |
java.util.Enumeration |
getCurrentLoggers()
Returns all the currently defined categories in this hierarchy as
an
Enumeration . |
Logger |
getLogger(java.lang.String name)
Return a new logger instance named as the first parameter using
the default factory.
|
Logger |
getLogger(java.lang.String name,
LoggerFactory factory)
Return a new logger instance named as the first parameter using
factory . |
RendererMap |
getRendererMap()
Get the renderer map for this hierarchy.
|
Logger |
getRootLogger()
Get the root of this hierarchy.
|
Level |
getThreshold()
Returns a
Level representation of the enable
state. |
ThrowableRenderer |
getThrowableRenderer()
Get throwable renderer.
|
boolean |
isDisabled(int level)
This method will return
true if this repository is
disabled for level object passed as parameter and
false otherwise. |
void |
overrideAsNeeded(java.lang.String override)
已过时。
Deprecated with no replacement.
|
void |
resetConfiguration()
Reset all values contained in this hierarchy instance to their
default.
|
void |
setDisableOverride(java.lang.String override)
已过时。
Deprecated with no replacement.
|
void |
setRenderer(java.lang.Class renderedClass,
ObjectRenderer renderer)
Used by subclasses to add a renderer to the hierarchy passed as parameter.
|
void |
setThreshold(Level l)
Enable logging for logging requests with level
l or
higher. |
void |
setThreshold(java.lang.String levelStr)
The string form of
setThreshold(Level) . |
void |
setThrowableRenderer(ThrowableRenderer renderer)
Set throwable renderer.
|
void |
shutdown()
Shutting down a hierarchy will safely close and remove
all appenders in all categories including the root logger.
|
public Hierarchy(Logger root)
root
- The root of the new hierarchy.public void addRenderer(java.lang.Class classToRender, ObjectRenderer or)
public void addHierarchyEventListener(HierarchyEventListener listener)
LoggerRepository
HierarchyEventListener
event to the repository.addHierarchyEventListener
在接口中 LoggerRepository
public void clear()
You should really know what you are doing before invoking this method.
public void emitNoAppenderWarning(Category cat)
emitNoAppenderWarning
在接口中 LoggerRepository
public Logger exists(java.lang.String name)
null
.exists
在接口中 LoggerRepository
name
- The name of the logger to search for.public void setThreshold(java.lang.String levelStr)
setThreshold(Level)
.setThreshold
在接口中 LoggerRepository
public void setThreshold(Level l)
l
or
higher. By default all levels are enabled.setThreshold
在接口中 LoggerRepository
l
- The minimum level for which logging requests are sent to
their appenders.public void fireAddAppenderEvent(Category logger, Appender appender)
fireAddAppenderEvent
在接口中 LoggerRepository
public Level getThreshold()
Level
representation of the enable
state.getThreshold
在接口中 LoggerRepository
public Logger getLogger(java.lang.String name)
If a logger of that name already exists, then it will be returned. Otherwise, a new logger will be instantiated and then linked with its existing ancestors as well as children.
getLogger
在接口中 LoggerRepository
name
- The name of the logger to retrieve.public Logger getLogger(java.lang.String name, LoggerFactory factory)
factory
.
If a logger of that name already exists, then it will be
returned. Otherwise, a new logger will be instantiated by the
factory
parameter and linked with its existing
ancestors as well as children.
getLogger
在接口中 LoggerRepository
name
- The name of the logger to retrieve.factory
- The factory that will make the new logger instance.public java.util.Enumeration getCurrentLoggers()
Enumeration
.
The root logger is not included in the returned
Enumeration
.
getCurrentLoggers
在接口中 LoggerRepository
public java.util.Enumeration getCurrentCategories()
getCurrentLoggers()
instead.LoggerRepository
LoggerRepository.getCurrentLoggers()
instead.getCurrentCategories
在接口中 LoggerRepository
public RendererMap getRendererMap()
getRendererMap
在接口中 RendererSupport
public Logger getRootLogger()
getRootLogger
在接口中 LoggerRepository
public boolean isDisabled(int level)
true
if this repository is
disabled for level
object passed as parameter and
false
otherwise. See also the threshold
emthod.isDisabled
在接口中 LoggerRepository
public void overrideAsNeeded(java.lang.String override)
public void resetConfiguration()
null
,
sets their additivity flag to true
and sets the level
of the root logger to DEBUG
. Moreover,
message disabling is set its default "off" value.
Existing categories are not removed. They are just reset.
This method should be used sparingly and with care as it will block all logging until it is completed.
resetConfiguration
在接口中 LoggerRepository
public void setDisableOverride(java.lang.String override)
public void setRenderer(java.lang.Class renderedClass, ObjectRenderer renderer)
setRenderer
在接口中 RendererSupport
public void setThrowableRenderer(ThrowableRenderer renderer)
setThrowableRenderer
在接口中 ThrowableRendererSupport
renderer
- renderer, may be null.public ThrowableRenderer getThrowableRenderer()
getThrowableRenderer
在接口中 ThrowableRendererSupport
public void shutdown()
Some appenders such as SocketAppender
and AsyncAppender
need to be closed before the
application exists. Otherwise, pending logging events might be
lost.
The shutdown
method is careful to close nested
appenders before closing regular appenders. This is allows
configurations where a regular appender is attached to a logger
and again to a nested appender.
shutdown
在接口中 LoggerRepository