java.lang.Object | |
↳ | org.apache.log4j.Hierarchy |
This class is specialized in retrieving loggers by name and also maintaining the logger hierarchy.
The casual user does not have to deal with this class directly.
The structure of the logger hierarchy is maintained by the
getLogger(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.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new logger hierarchy.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add a
HierarchyEventListener event to the repository. | |||||||||||
Add an object renderer for a specific class.
| |||||||||||
This call will clear all logger definitions from the internal
hashtable.
| |||||||||||
Check if the named logger exists in the hierarchy.
| |||||||||||
This method is deprecated.
Please use
getCurrentLoggers() instead.
| |||||||||||
Returns all the currently defined categories in this hierarchy as
an java.util.Enumeration Enumeration.
| |||||||||||
Return a new logger instance named as the first parameter using
the default factory.
| |||||||||||
Return a new logger instance named as the first parameter using
factory . | |||||||||||
Get the renderer map for this hierarchy.
| |||||||||||
Get the root of this hierarchy.
| |||||||||||
Returns a
Level representation of the enable
state. | |||||||||||
Get throwable renderer.
| |||||||||||
This method will return
true if this repository is
disabled for level object passed as parameter and
false otherwise. | |||||||||||
This method is deprecated.
Deprecated with no replacement.
| |||||||||||
Reset all values contained in this hierarchy instance to their
default.
| |||||||||||
This method is deprecated.
Deprecated with no replacement.
| |||||||||||
Used by subclasses to add a renderer to the hierarchy passed as parameter.
| |||||||||||
The string form of
setThreshold(Level) . | |||||||||||
Enable logging for logging requests with level
l or
higher. | |||||||||||
Set throwable renderer.
| |||||||||||
Shutting down a hierarchy will safely close and remove
all appenders in all categories including the root logger.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
org.apache.log4j.spi.LoggerRepository
| |||||||||||
From interface
org.apache.log4j.spi.RendererSupport
| |||||||||||
From interface
org.apache.log4j.spi.ThrowableRendererSupport
|
Create a new logger hierarchy.
root | The root of the new hierarchy. |
---|
Add a HierarchyEventListener
event to the repository.
Add an object renderer for a specific class.
This call will clear all logger definitions from the internal hashtable. Invoking this method will irrevocably mess up the logger hierarchy.
You should really know what you are doing before invoking this method.
Check if the named logger exists in the hierarchy. If so return
its reference, otherwise returns null
.
name | The name of the logger to search for. |
---|
This method is deprecated.
Please use getCurrentLoggers()
instead.
Deprecated. Please use getCurrentLoggers()
instead.
Returns all the currently defined categories in this hierarchy as an java.util.Enumeration Enumeration.
The root logger is not included in the returned Enumeration.
Return a new logger instance named as the first parameter using the default factory.
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.
name | The name of the logger to retrieve. |
---|
Return a new logger instance named as the first parameter using
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.
name | The name of the logger to retrieve. |
---|---|
factory | The factory that will make the new logger instance. |
Get throwable renderer.
This method will return true
if this repository is
disabled for level
object passed as parameter and
false
otherwise. See also the threshold
emthod.
This method is deprecated.
Deprecated with no replacement.
Reset all values contained in this hierarchy instance to their
default. This removes all appenders from all categories, sets
the level of all non-root categories to 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.
This method is deprecated.
Deprecated with no replacement.
Does nothing.
Used by subclasses to add a renderer to the hierarchy passed as parameter.
Enable logging for logging requests with level l
or
higher. By default all levels are enabled.
l | The minimum level for which logging requests are sent to their appenders. |
---|
Set throwable renderer.
renderer | renderer, may be null. |
---|
Shutting down a hierarchy will safely close and remove all appenders in all categories including the root logger.
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.