org.apache.log
Class Hierarchy
public class Hierarchy
extends java.lang.Object
This class encapsulates a basic independent log hierarchy.
The hierarchy is essentially a safe wrapper around root logger.
DEFAULT_FORMAT
public static final String DEFAULT_FORMAT
c_hierarchy
private static final Hierarchy c_hierarchy
m_rootLogger
private Logger m_rootLogger
Hierarchy
public Hierarchy()
Create a hierarchy object.
The default LogTarget writes to stdout.
addLoggerListener
public void addLoggerListener(LoggerListener loggerListener)
Set the LoggerListener associated with hierarchy. This is a
unicast listener, so only one LoggerListener is allowed.
loggerListener
- the LoggerListener
getDefaultHierarchy
public static Hierarchy getDefaultHierarchy()
Retrieve the default hierarchy.
In most cases the default LogHierarchy is the only
one used in an application. However when security is
a concern or multiple independent applications will
be running in same JVM it is advantageous to create
new Hierarchies rather than reuse default.
getLoggerFor
public Logger getLoggerFor(String category)
Retrieve a logger for named category.
getRootLogger
public final Logger getRootLogger()
Utility method to retrieve logger for hierarchy.
This method is intended for use by sub-classes
which can take responsibility for manipulating
Logger directly.
notifyLoggerCreated
private void notifyLoggerCreated(String category,
Logger logger)
Notify logger listener (if any) that a new logger was created.
category
- the category of new loggerlogger
- the logger
removeLoggerListener
public void removeLoggerListener(LoggerListener loggerListener)
Remove the LoggerListener associated with hierarchy. Perform this
step before adding a new one if you want to change it.
loggerListener
- the LoggerListener
setDefaultLogTarget
public void setDefaultLogTarget(LogTarget target)
Set the default log target for hierarchy.
This is the target inherited by loggers if no other target is specified.
target
- the default target
setDefaultLogTargets
public void setDefaultLogTargets(LogTarget[] targets)
Set the default log targets for this hierarchy.
These are the targets inherited by loggers if no other targets are specified
targets
- the default targets
setDefaultPriority
public void setDefaultPriority(Priority priority)
Set the default priority for hierarchy.
This is the priority inherited by loggers if no other priority is specified.
priority
- the default priority
setErrorHandler
public void setErrorHandler(ErrorHandler errorHandler)
Set the ErrorHandler associated with hierarchy.
errorHandler
- the ErrorHandler