Class Hierarchy
java.lang.Object
org.apache.log.Hierarchy
This class encapsulates a basic independent log hierarchy.
The hierarchy is essentially a safe wrapper around root logger.
- Author:
- Avalon Development Team, Peter Donald
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate classInner class to redirect to hierarchys real LoggerListener if any. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final HierarchyThe instance of default hierarchystatic final StringFormat of default formatterprivate ErrorHandlerError Handler associated with hierarchyprivate LoggerListenerLoggerListener associated with hierarchyprivate LoggerThe root logger which contains all Loggers in this hierarchy -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLoggerListener(LoggerListener loggerListener) Set the LoggerListener associated with hierarchy.static HierarchyRetrieve the default hierarchy.getLoggerFor(String category) Retrieve a logger for named category.final LoggerUtility method to retrieve logger for hierarchy.private voidnotifyLoggerCreated(String category, Logger logger) Notify logger listener (if any) that a new logger was created.voidremoveLoggerListener(LoggerListener loggerListener) Remove the LoggerListener associated with hierarchy.voidsetDefaultLogTarget(LogTarget target) Set the default log target for hierarchy.voidsetDefaultLogTargets(LogTarget[] targets) Set the default log targets for this hierarchy.voidsetDefaultPriority(Priority priority) Set the default priority for hierarchy.voidsetErrorHandler(ErrorHandler errorHandler) Set the ErrorHandler associated with hierarchy.
-
Field Details
-
DEFAULT_FORMAT
-
c_hierarchy
The instance of default hierarchy -
m_errorHandler
Error Handler associated with hierarchy -
m_rootLogger
The root logger which contains all Loggers in this hierarchy -
m_loggerListener
LoggerListener associated with hierarchy
-
-
Constructor Details
-
Hierarchy
public Hierarchy()Create a hierarchy object. The default LogTarget writes to stdout.
-
-
Method Details
-
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.
- Returns:
- the default Hierarchy
-
setDefaultLogTarget
Set the default log target for hierarchy. This is the target inherited by loggers if no other target is specified.- Parameters:
target- the default target
-
setDefaultLogTargets
Set the default log targets for this hierarchy. These are the targets inherited by loggers if no other targets are specified- Parameters:
targets- the default targets
-
setDefaultPriority
Set the default priority for hierarchy. This is the priority inherited by loggers if no other priority is specified.- Parameters:
priority- the default priority
-
setErrorHandler
Set the ErrorHandler associated with hierarchy.- Parameters:
errorHandler- the ErrorHandler
-
addLoggerListener
Set the LoggerListener associated with hierarchy. This is a unicast listener, so only one LoggerListener is allowed.- Parameters:
loggerListener- the LoggerListener- Throws:
UnsupportedOperationException- if no more LoggerListeners are permitted.
-
removeLoggerListener
Remove the LoggerListener associated with hierarchy. Perform this step before adding a new one if you want to change it.- Parameters:
loggerListener- the LoggerListener
-
getLoggerFor
-
notifyLoggerCreated
-
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.- Returns:
- the Logger
-