|
Log4j 1.3alpha-8 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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(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.
Constructor Summary | |
Hierarchy(Logger root)
Create a new logger hierarchy. |
Method Summary | |
void |
addErrorItem(ErrorItem errorItem)
Add an error item to the list of previously encountered errors. |
void |
addHierarchyEventListener(HierarchyEventListener listener)
Deprecated. Superceded by addLoggerEventListener |
void |
addLoggerEventListener(LoggerEventListener listener)
Add a LoggerEventListener to the repository. |
void |
addLoggerRepositoryEventListener(LoggerRepositoryEventListener listener)
Add a LoggerRepositoryEventListener to the repository. |
void |
addRenderer(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(String name)
Check if the named logger exists in the hierarchy. |
void |
fireAddAppenderEvent(Category logger,
Appender appender)
Requests that a appender added event be sent to any registered LoggerEventListener . |
void |
fireAddAppenderEvent(Logger logger,
Appender appender)
Requests that a appender added event be sent to any registered LoggerEventListener . |
void |
fireConfigurationChangedEvent()
Requests that a configuration changed event be sent to any registered LoggerRepositoryEventListener . |
void |
fireLevelChangedEvent(Logger logger)
Requests that a level changed event be sent to any registered LoggerEventListener . |
void |
fireRemoveAppenderEvent(Category logger,
Appender appender)
Requests that a appender removed event be sent to any registered LoggerEventListener . |
void |
fireRemoveAppenderEvent(Logger logger,
Appender appender)
Requests that a appender removed event be sent to any registered LoggerEventListener . |
Enumeration |
getCurrentCategories()
Deprecated. |
Enumeration |
getCurrentLoggers()
Returns all the currently defined categories in this hierarchy as an Enumeration . |
List |
getErrorList()
Return the the list of previously encoutered error items . |
Logger |
getLogger(String name)
Return a new logger instance named as the first parameter using the default factory. |
Logger |
getLogger(String name,
LoggerFactory factory)
Return a new logger instance named as the first parameter using factory . |
String |
getName()
Return the name of this hierarchy. |
Object |
getObject(String key)
A LoggerRepository can also act as a store for various objects used by log4j components. |
PluginRegistry |
getPluginRegistry()
Return the PluginRegisty for this LoggerRepository. |
Map |
getProperties()
Get the properties specific for this repository. |
String |
getProperty(String key)
Get the property of this repository. |
RendererMap |
getRendererMap()
Get the renderer map for this hierarchy. |
Logger |
getRootLogger()
Get the root of this hierarchy. |
org.apache.log4j.scheduler.Scheduler |
getScheduler()
Return this repository's own scheduler. |
Level |
getThreshold()
Returns a Level representation of the enable
state. |
boolean |
isDisabled(int level)
This method will return true if this repository is
disabled for level object passed as parameter and
false otherwise. |
boolean |
isPristine()
Is the current configuration of the repository in its original (pristine) state? |
void |
putObject(String key,
Object value)
Store an object under 'key'. |
void |
removeLoggerEventListener(LoggerEventListener listener)
Remove a LoggerEventListener from the repository. |
void |
removeLoggerRepositoryEventListener(LoggerRepositoryEventListener listener)
Remove a LoggerRepositoryEventListener from the repository. |
void |
resetConfiguration()
Reset all values contained in this hierarchy instance to their default. |
void |
setName(String repoName)
A logger repository is a named entity. |
void |
setPristine(boolean state)
Set the pristine flag. |
void |
setProperty(String key,
String value)
Set a property of this repository. |
void |
setRenderer(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(String levelStr)
The string form of setThreshold(Level) . |
void |
shutdown()
Shutting down a hierarchy will safely close and remove all appenders in all categories including the root logger. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Hierarchy(Logger root)
root
- The root of the new hierarchy.Method Detail |
public void addRenderer(Class classToRender, ObjectRenderer or)
public void addLoggerRepositoryEventListener(LoggerRepositoryEventListener listener)
LoggerRepositoryEventListener
to the repository. The
listener will be called when repository events occur.addLoggerRepositoryEventListener
in interface LoggerRepositoryEx
public void removeLoggerRepositoryEventListener(LoggerRepositoryEventListener listener)
LoggerRepositoryEventListener
from the repository.removeLoggerRepositoryEventListener
in interface LoggerRepositoryEx
public void addLoggerEventListener(LoggerEventListener listener)
LoggerEventListener
to the repository. The listener
will be called when repository events occur.addLoggerEventListener
in interface LoggerRepositoryEx
public void addHierarchyEventListener(HierarchyEventListener listener)
HierarchyEventListener
event to the repository.addHierarchyEventListener
in interface LoggerRepository
public void removeLoggerEventListener(LoggerEventListener listener)
LoggerEventListener
from the repository.removeLoggerEventListener
in interface LoggerRepositoryEx
public void clear()
You should really know what you are doing before invoking this method.
public void emitNoAppenderWarning(Category cat)
emitNoAppenderWarning
in interface LoggerRepository
public Logger exists(String name)
null
.exists
in interface LoggerRepository
name
- The name of the logger to search for.public String getName()
getName
in interface LoggerRepositoryEx
org.apache.log4j.spi.LoggerRepositoryEx
public void setName(String repoName)
LoggerRepositoryEx
setName
in interface LoggerRepositoryEx
org.apache.log4j.spi.LoggerRepositoryEx
repoName
- new name, may not be null.public Map getProperties()
LoggerRepositoryEx
getProperties
in interface LoggerRepositoryEx
org.apache.log4j.spi.LoggerRepositoryEx
public String getProperty(String key)
LoggerRepositoryEx
getProperty
in interface LoggerRepositoryEx
org.apache.log4j.spi.LoggerRepositoryEx
key
- property key.public void setProperty(String key, String value)
LoggerRepositoryEx
setProperty
in interface LoggerRepositoryEx
org.apache.log4j.spi.LoggerRepositoryEx
key
- key, may not be null.value
- new value, if null, property will be removed.public void setThreshold(String levelStr)
setThreshold(Level)
.setThreshold
in interface LoggerRepository
public void setThreshold(Level l)
l
or
higher. By default all levels are enabled.setThreshold
in interface LoggerRepository
l
- The minimum level for which logging requests are sent to
their appenders.public PluginRegistry getPluginRegistry()
LoggerRepositoryEx
getPluginRegistry
in interface LoggerRepositoryEx
org.apache.log4j.spi.LoggerRepositoryEx
public void fireAddAppenderEvent(Category logger, Appender appender)
LoggerEventListener
.fireAddAppenderEvent
in interface LoggerRepository
logger
- The logger to which the appender was added.appender
- The appender added to the logger.public void fireAddAppenderEvent(Logger logger, Appender appender)
LoggerEventListener
.logger
- The logger to which the appender was added.appender
- The appender added to the logger.public void fireRemoveAppenderEvent(Category logger, Appender appender)
LoggerEventListener
.fireRemoveAppenderEvent
in interface LoggerRepositoryEx
logger
- The logger from which the appender was removed.appender
- The appender removed from the logger.public void fireRemoveAppenderEvent(Logger logger, Appender appender)
LoggerEventListener
.logger
- The logger from which the appender was removed.appender
- The appender removed from the logger.public void fireLevelChangedEvent(Logger logger)
LoggerEventListener
.fireLevelChangedEvent
in interface LoggerRepositoryEx
logger
- The logger which changed levels.public void fireConfigurationChangedEvent()
LoggerRepositoryEventListener
.fireConfigurationChangedEvent
in interface LoggerRepositoryEx
public Level getThreshold()
Level
representation of the enable
state.getThreshold
in interface LoggerRepository
public Logger getLogger(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
in interface LoggerRepository
name
- The name of the logger to retrieve.public Logger getLogger(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
in interface LoggerRepository
name
- The name of the logger to retrieve.factory
- The factory that will make the new logger instance.public Enumeration getCurrentLoggers()
Enumeration
.
The root logger is not included in the returned
Enumeration
.
getCurrentLoggers
in interface LoggerRepository
public List getErrorList()
error items
.getErrorList
in interface LoggerRepositoryEx
org.apache.log4j.spi.LoggerRepositoryEx
public void addErrorItem(ErrorItem errorItem)
addErrorItem
in interface LoggerRepositoryEx
public Enumeration getCurrentCategories()
getCurrentLoggers()
instead.
LoggerRepository
LoggerRepository.getCurrentLoggers()
instead.getCurrentCategories
in interface LoggerRepository
public RendererMap getRendererMap()
getRendererMap
in interface RendererSupport
public Logger getRootLogger()
getRootLogger
in interface 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
in interface LoggerRepository
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
in interface LoggerRepository
public void setRenderer(Class renderedClass, ObjectRenderer renderer)
setRenderer
in interface RendererSupport
public boolean isPristine()
LoggerRepositoryEx
isPristine
in interface LoggerRepositoryEx
org.apache.log4j.spi.LoggerRepositoryEx
public void setPristine(boolean state)
LoggerRepositoryEx
setPristine
in interface LoggerRepositoryEx
org.apache.log4j.spi.LoggerRepositoryEx
state
- stateLoggerRepositoryEx.isPristine()
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
in interface LoggerRepository
public org.apache.log4j.scheduler.Scheduler getScheduler()
getScheduler
in interface LoggerRepositoryEx
public void putObject(String key, Object value)
LoggerRepositoryEx
putObject
in interface LoggerRepositoryEx
org.apache.log4j.spi.LoggerRepositoryEx
key
- key, may not be null.value
- value, may be null.public Object getObject(String key)
LoggerRepositoryEx
getObject
in interface LoggerRepositoryEx
org.apache.log4j.spi.LoggerRepositoryEx
key
- key, may not be null.
|
Log4j 1.3alpha-8 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |