Top Description Inners Fields Constructors Methods
org.apache.log

public Class Hierarchy

extends Object
Class Inheritance
Imports
org.apache.log.format.PatternFormatter, org.apache.log.output.io.StreamTarget, org.apache.log.util.DefaultErrorHandler, .LoggerListener

This class encapsulates a basic independent log hierarchy. The hierarchy is essentially a safe wrapper around root logger.
Authors
Avalon Development Team, Peter Donald

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
Hierarchy.InnerLoggerListener

Inner class to redirect to hierarchys real LoggerListener if any.

Field Summary

Modifier and TypeField and Description
private static final Hierarchy
public static final String
private ErrorHandler
private LoggerListener
private Logger

Constructor Summary

AccessConstructor and Description
public
Hierarchy()

Create a hierarchy object.

Method Summary

Modifier and TypeMethod and Description
public synchronized void
addLoggerListener(final LoggerListener
the LoggerListener
loggerListener
)

Set the LoggerListener associated with hierarchy.

public static Hierarchy

Returns:

the default Hierarchy
getDefaultHierarchy
()

Retrieve the default hierarchy.

public Logger

Returns:

the Logger
getLoggerFor
(final String
the context
category
)

Retrieve a logger for named category.

public final Logger

Returns:

the Logger
getRootLogger
()

Utility method to retrieve logger for hierarchy.

private synchronized void
notifyLoggerCreated(final String
the category of new logger
category
,
final Logger
the logger
logger
)

Notify logger listener (if any) that a new logger was created.

public synchronized void
removeLoggerListener(final LoggerListener
the LoggerListener
loggerListener
)

Remove the LoggerListener associated with hierarchy.

public void
setDefaultLogTarget(final LogTarget
the default target
target
)

Set the default log target for hierarchy.

public void
setDefaultLogTargets(final LogTarget[]
the default targets
targets
)

Set the default log targets for this hierarchy.

public void
setDefaultPriority(final Priority
the default priority
priority
)

Set the default priority for hierarchy.

public void
setErrorHandler(final ErrorHandler
the ErrorHandler
errorHandler
)

Set the ErrorHandler associated with hierarchy.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

c_hierarchyback to summary
private static final Hierarchy c_hierarchy
DEFAULT_FORMATback to summary
public static final String DEFAULT_FORMAT
m_errorHandlerback to summary
private ErrorHandler m_errorHandler
m_loggerListenerback to summary
private LoggerListener m_loggerListener
m_rootLoggerback to summary
private Logger m_rootLogger

Constructor Detail

Hierarchyback to summary
public Hierarchy()

Create a hierarchy object. The default LogTarget writes to stdout.

Method Detail

addLoggerListenerback to summary
public synchronized void addLoggerListener(final LoggerListener loggerListener)

Set the LoggerListener associated with hierarchy. This is a unicast listener, so only one LoggerListener is allowed.

Parameters
loggerListener:LoggerListener

the LoggerListener

Exceptions
UnsupportedOperationException:
if no more LoggerListeners are permitted.
getDefaultHierarchyback to summary
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.

Returns:Hierarchy

the default Hierarchy

getLoggerForback to summary
public Logger getLoggerFor(final String category)

Retrieve a logger for named category.

Parameters
category:String

the context

Returns:Logger

the Logger

getRootLoggerback to summary
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.

Returns:Logger

the Logger

notifyLoggerCreatedback to summary
private synchronized void notifyLoggerCreated(final String category, final Logger logger)

Notify logger listener (if any) that a new logger was created.

Parameters
category:String

the category of new logger

logger:Logger

the logger

removeLoggerListenerback to summary
public synchronized void removeLoggerListener(final LoggerListener loggerListener)

Remove the LoggerListener associated with hierarchy. Perform this step before adding a new one if you want to change it.

Parameters
loggerListener:LoggerListener

the LoggerListener

setDefaultLogTargetback to summary
public void setDefaultLogTarget(final LogTarget target)

Set the default log target for hierarchy. This is the target inherited by loggers if no other target is specified.

Parameters
target:LogTarget

the default target

setDefaultLogTargetsback to summary
public void setDefaultLogTargets(final LogTarget[] targets)

Set the default log targets for this hierarchy. These are the targets inherited by loggers if no other targets are specified

Parameters
targets:LogTarget[]

the default targets

setDefaultPriorityback to summary
public void setDefaultPriority(final Priority priority)

Set the default priority for hierarchy. This is the priority inherited by loggers if no other priority is specified.

Parameters
priority:Priority

the default priority

setErrorHandlerback to summary
public void setErrorHandler(final ErrorHandler errorHandler)

Set the ErrorHandler associated with hierarchy.

Parameters
errorHandler:ErrorHandler

the ErrorHandler

org.apache.log back to summary

private Class Hierarchy.InnerErrorHandler

extends Object
implements ErrorHandler
Class Inheritance
All Implemented Interfaces
org.apache.log.ErrorHandler

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
error(final String
the error message
message
,
final Throwable
the exception associated with error (may be null)
throwable
,
final LogEvent
the LogEvent that caused error, if any (may be null)
event
)

Implements org.apache.log.ErrorHandler.error.

Log an unrecoverable error.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

InnerErrorHandlerback to summary
private InnerErrorHandler()

Method Detail

errorback to summary
public void error(final String message, final Throwable throwable, final LogEvent event)

Implements org.apache.log.ErrorHandler.error.

Log an unrecoverable error.

Parameters
message:String

the error message

throwable:Throwable

the exception associated with error (may be null)

event:LogEvent

the LogEvent that caused error, if any (may be null)

org.apache.log back to summary

private Class Hierarchy.InnerLoggerListener

extends LoggerListener
Class Inheritance

Inner class to redirect to hierarchys real LoggerListener if any. Used so that all the loggers will not have to be updated when LoggerListener changes.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
loggerCreated(final String
the category of logger
category
,
final Logger
the logger object
logger
)

Implements abstract org.apache.log.util.LoggerListener.loggerCreated.

Notify listener that a logger was created.

Constructor Detail

InnerLoggerListenerback to summary
private InnerLoggerListener()

Method Detail

loggerCreatedback to summary
public void loggerCreated(final String category, final Logger logger)

Implements abstract org.apache.log.util.LoggerListener.loggerCreated.

Notify listener that a logger was created.

Parameters
category:String

the category of logger

logger:Logger

the logger object