Log4j 1.2.13 | |
Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.log4j.Hierarchy
getLogger
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.
Method Summary | |
void | |
void |
|
void |
|
void | |
Logger |
|
void |
|
Enumeration |
|
Enumeration |
|
Logger |
|
Logger |
|
RendererMap |
|
Logger |
|
Level |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
public Hierarchy(Logger root)
Create a new logger hierarchy.
- Parameters:
root
- The root of the new hierarchy.
public void addHierarchyEventListener(HierarchyEventListener listener)
- Specified by:
- addHierarchyEventListener in interface LoggerRepository
public void addRenderer(Class classToRender, ObjectRenderer or)
Add an object renderer for a specific class.
public void clear()
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.
- Since:
- 0.9.0
public void emitNoAppenderWarning(Category cat)
- Specified by:
- emitNoAppenderWarning in interface LoggerRepository
public Logger exists(String name)
Check if the named logger exists in the hierarchy. If so return its reference, otherwise returnsnull
.
- Specified by:
- exists in interface LoggerRepository
- Parameters:
name
- The name of the logger to search for.
public void fireAddAppenderEvent(Category logger, Appender appender)
- Specified by:
- fireAddAppenderEvent in interface LoggerRepository
public Enumeration getCurrentCategories()
Deprecated. Please use
getCurrentLoggers()
instead.
- Specified by:
- getCurrentCategories in interface LoggerRepository
public Enumeration getCurrentLoggers()
Returns all the currently defined categories in this hierarchy as anEnumeration
. The root logger is not included in the returnedEnumeration
.
- Specified by:
- getCurrentLoggers in interface LoggerRepository
public Logger getLogger(String name)
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.
- Specified by:
- getLogger in interface LoggerRepository
- Parameters:
name
- The name of the logger to retrieve.
public Logger getLogger(String name, LoggerFactory factory)
Return a new logger instance named as the first parameter usingfactory
. If a logger of that name already exists, then it will be returned. Otherwise, a new logger will be instantiated by thefactory
parameter and linked with its existing ancestors as well as children.
- Specified by:
- getLogger in interface LoggerRepository
- Parameters:
name
- The name of the logger to retrieve.factory
- The factory that will make the new logger instance.
public RendererMap getRendererMap()
Get the renderer map for this hierarchy.
- Specified by:
- getRendererMap in interface RendererSupport
public Logger getRootLogger()
Get the root of this hierarchy.
- Specified by:
- getRootLogger in interface LoggerRepository
- Since:
- 0.9.0
public Level getThreshold()
Returns aLevel
representation of theenable
state.
- Specified by:
- getThreshold in interface LoggerRepository
- Since:
- 1.2
public boolean isDisabled(int level)
This method will returntrue
if this repository is disabled forlevel
object passed as parameter andfalse
otherwise. See also thethreshold
emthod.
- Specified by:
- isDisabled in interface LoggerRepository
public void overrideAsNeeded(String override)
Deprecated. Deprecated with no replacement.
public void resetConfiguration()
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 tonull
, sets their additivity flag totrue
and sets the level of the root logger toDEBUG
. 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.
- Specified by:
- resetConfiguration in interface LoggerRepository
- Since:
- 0.8.5
public void setDisableOverride(String override)
Deprecated. Deprecated with no replacement.
Does mothing.
public void setRenderer(Class renderedClass, ObjectRenderer renderer)
Used by subclasses to add a renderer to the hierarchy passed as parameter.
- Specified by:
- setRenderer in interface RendererSupport
public void setThreshold(String levelStr)
The string form ofsetThreshold(Level)
.
- Specified by:
- setThreshold in interface LoggerRepository
public void setThreshold(Level l)
Enable logging for logging requests with levell
or higher. By default all levels are enabled.
- Specified by:
- setThreshold in interface LoggerRepository
- Parameters:
l
- The minimum level for which logging requests are sent to their appenders.
public void shutdown()
Shutting down a hierarchy will safely close and remove all appenders in all categories including the root logger. Some appenders such asSocketAppender
andAsyncAppender
need to be closed before the application exists. Otherwise, pending logging events might be lost. Theshutdown
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.
- Specified by:
- shutdown in interface LoggerRepository
- Since:
- 1.0