public final class LoggerRepositoryExImpl extends Object implements LoggerRepositoryEx, org.apache.log4j.spi.RendererSupport, org.apache.log4j.xml.UnrecognizedElementHandler
Constructor and Description |
---|
LoggerRepositoryExImpl(org.apache.log4j.spi.LoggerRepository repository)
Constructs a new logger hierarchy.
|
Modifier and Type | Method and Description |
---|---|
void |
addErrorItem(ErrorItem errorItem)
Add an error item to the list of previously encountered errors.
|
void |
addHierarchyEventListener(org.apache.log4j.spi.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 |
emitNoAppenderWarning(org.apache.log4j.Category cat)
Issue warning that there are no appenders in hierarchy.
|
org.apache.log4j.Logger |
exists(String loggerName)
Check if the named logger exists in the hierarchy.
|
void |
fireAddAppenderEvent(org.apache.log4j.Category logger,
org.apache.log4j.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(org.apache.log4j.Logger logger)
Requests that a level changed event be sent to any registered
LoggerEventListener . |
void |
fireRemoveAppenderEvent(org.apache.log4j.Category logger,
org.apache.log4j.Appender appender)
Requests that a appender removed event be sent to any registered
LoggerEventListener . |
Enumeration |
getCurrentCategories()
Deprecated.
Please use
getCurrentLoggers() instead. |
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 . |
org.apache.log4j.Logger |
getLogger(String loggerName)
Return a new logger instance named as the first parameter using
the default factory.
|
org.apache.log4j.Logger |
getLogger(String loggerName,
org.apache.log4j.spi.LoggerFactory factory)
Return a new logger instance named as the first parameter using
factory . |
org.apache.log4j.spi.LoggerFactory |
getLoggerFactory()
Get logger factory.
|
String |
getName()
Return the name of this hierarchy.
|
Object |
getObject(String key)
Get object by key.
|
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.
|
org.apache.log4j.or.RendererMap |
getRendererMap()
Get the renderer map for this hierarchy.
|
org.apache.log4j.Logger |
getRootLogger()
Get the root of this hierarchy.
|
Scheduler |
getScheduler()
Return this repository's own scheduler.
|
org.apache.log4j.Level |
getThreshold()
Returns the current threshold.
|
boolean |
isDisabled(int level)
This method will return
true if this repository is
disabled for level value passed as parameter and
false otherwise. |
boolean |
isPristine()
Is the current configuration of the repository in its original (pristine)
state?
|
boolean |
parseUnrecognizedElement(Element element,
Properties props) |
void |
putObject(String key,
Object value)
Puts object by 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 |
setLoggerFactory(org.apache.log4j.spi.LoggerFactory factory)
Set logger factory.
|
void |
setName(String repoName)
Set the name of this repository.
|
void |
setPristine(boolean state)
Set the pristine flag.
|
void |
setProperty(String key,
String value)
Set a property by key and value.
|
void |
setRenderer(Class renderedClass,
org.apache.log4j.or.ObjectRenderer renderer)
Used by subclasses to add a renderer to the hierarchy passed as parameter.
|
void |
setThreshold(org.apache.log4j.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.
|
public LoggerRepositoryExImpl(org.apache.log4j.spi.LoggerRepository repository)
repository
- Base implementation of repository.public void addLoggerRepositoryEventListener(LoggerRepositoryEventListener listener)
LoggerRepositoryEventListener
to the repository. The
listener will be called when repository events occur.addLoggerRepositoryEventListener
in interface LoggerRepositoryEx
listener
- listenerpublic void removeLoggerRepositoryEventListener(LoggerRepositoryEventListener listener)
LoggerRepositoryEventListener
from the repository.removeLoggerRepositoryEventListener
in interface LoggerRepositoryEx
listener
- listenerpublic void addLoggerEventListener(LoggerEventListener listener)
LoggerEventListener
to the repository. The listener
will be called when repository events occur.addLoggerEventListener
in interface LoggerRepositoryEx
listener
- listenerpublic void addHierarchyEventListener(org.apache.log4j.spi.HierarchyEventListener listener)
HierarchyEventListener
event to the repository.addHierarchyEventListener
in interface org.apache.log4j.spi.LoggerRepository
listener
- listenerpublic void removeLoggerEventListener(LoggerEventListener listener)
LoggerEventListener
from the repository.removeLoggerEventListener
in interface LoggerRepositoryEx
listener
- listener to be removedpublic void emitNoAppenderWarning(org.apache.log4j.Category cat)
emitNoAppenderWarning
in interface org.apache.log4j.spi.LoggerRepository
cat
- logger, not currently used.public org.apache.log4j.Logger exists(String loggerName)
null
.exists
in interface org.apache.log4j.spi.LoggerRepository
loggerName
- The name of the logger to search for.public String getName()
getName
in interface LoggerRepositoryEx
public void setName(String repoName)
setName
in interface LoggerRepositoryEx
repoName
- name of hierarchypublic Map getProperties()
getProperties
in interface LoggerRepositoryEx
public String getProperty(String key)
getProperty
in interface LoggerRepositoryEx
key
- property key.public void setProperty(String key, String value)
setProperty
in interface LoggerRepositoryEx
key
- property namevalue
- property valuepublic void setThreshold(String levelStr)
setThreshold(Level)
.setThreshold
in interface org.apache.log4j.spi.LoggerRepository
levelStr
- symbolic name for levelpublic void setThreshold(org.apache.log4j.Level l)
l
or
higher. By default all levels are enabled.setThreshold
in interface org.apache.log4j.spi.LoggerRepository
l
- The minimum level for which logging requests are sent to
their appenders.public PluginRegistry getPluginRegistry()
getPluginRegistry
in interface LoggerRepositoryEx
public void fireAddAppenderEvent(org.apache.log4j.Category logger, org.apache.log4j.Appender appender)
LoggerEventListener
.fireAddAppenderEvent
in interface org.apache.log4j.spi.LoggerRepository
logger
- The logger to which the appender was added.appender
- The appender added to the logger.public void fireRemoveAppenderEvent(org.apache.log4j.Category logger, org.apache.log4j.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 fireLevelChangedEvent(org.apache.log4j.Logger logger)
LoggerEventListener
.fireLevelChangedEvent
in interface LoggerRepositoryEx
logger
- The logger which changed levels.public void fireConfigurationChangedEvent()
LoggerRepositoryEventListener
.fireConfigurationChangedEvent
in interface LoggerRepositoryEx
public org.apache.log4j.Level getThreshold()
getThreshold
in interface org.apache.log4j.spi.LoggerRepository
public org.apache.log4j.Logger getLogger(String loggerName)
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 org.apache.log4j.spi.LoggerRepository
loggerName
- The name of the logger to retrieve.public org.apache.log4j.Logger getLogger(String loggerName, org.apache.log4j.spi.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 org.apache.log4j.spi.LoggerRepository
loggerName
- 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 org.apache.log4j.spi.LoggerRepository
public List getErrorList()
error items
.getErrorList
in interface LoggerRepositoryEx
public void addErrorItem(ErrorItem errorItem)
addErrorItem
in interface LoggerRepositoryEx
errorItem
- error to add to list of errors.public Enumeration getCurrentCategories()
getCurrentLoggers()
instead.getCurrentCategories
in interface org.apache.log4j.spi.LoggerRepository
public org.apache.log4j.or.RendererMap getRendererMap()
getRendererMap
in interface org.apache.log4j.spi.RendererSupport
public org.apache.log4j.Logger getRootLogger()
getRootLogger
in interface org.apache.log4j.spi.LoggerRepository
public boolean isDisabled(int level)
true
if this repository is
disabled for level
value passed as parameter and
false
otherwise. See also the threshold
method.isDisabled
in interface org.apache.log4j.spi.LoggerRepository
level
- numeric value for level.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 org.apache.log4j.spi.LoggerRepository
public void setRenderer(Class renderedClass, org.apache.log4j.or.ObjectRenderer renderer)
setRenderer
in interface org.apache.log4j.spi.RendererSupport
renderedClass
- classrenderer
- object used to render class.public boolean isPristine()
isPristine
in interface LoggerRepositoryEx
public void setPristine(boolean state)
setPristine
in interface LoggerRepositoryEx
state
- stateLoggerRepositoryEx.isPristine()
public void shutdown()
Some appenders such as org.apache.log4j.net.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 org.apache.log4j.spi.LoggerRepository
public Scheduler getScheduler()
getScheduler
in interface LoggerRepositoryEx
public void putObject(String key, Object value)
putObject
in interface LoggerRepositoryEx
key
- key, may not be null.value
- object to associate with key.public Object getObject(String key)
getObject
in interface LoggerRepositoryEx
key
- key, may not be null.public void setLoggerFactory(org.apache.log4j.spi.LoggerFactory factory)
setLoggerFactory
in interface LoggerRepositoryEx
factory
- logger factory.public org.apache.log4j.spi.LoggerFactory getLoggerFactory()
getLoggerFactory
in interface LoggerRepositoryEx
public boolean parseUnrecognizedElement(Element element, Properties props) throws Exception
parseUnrecognizedElement
in interface org.apache.log4j.xml.UnrecognizedElementHandler
Exception
Copyright © 2002-2017 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache Chainsaw, Chainsaw, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.