## Class LoggerHierarchy

Description

This class is specialized in retrieving loggers by name and also maintaining the logger hierarchy. The logger hierarchy is dealing with the several Log-Levels Logger can have. From log4j website:

"A logger is said to be an ancestor of another logger if its name followed by a dot is a prefix of the descendant logger name. A logger is said to be a parent of a child logger if there are no ancestors between itself and the descendant logger."

Child Loggers do inherit their Log-Levels from their Ancestors. They can increase their Log-Level compared to their Ancestors, but they cannot decrease it.

<p>The casual user does not have to deal with this class directly.</p>

<p>The structure of the logger hierarchy is maintained by the getLogger 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.</p>

<p>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.</p>

- version: $Revision: 1394956 $

Located in /log4php/LoggerHierarchy.php (line 50)

Variable Summary
mixed $loggers
LoggerRendererMap $rendererMap
RootLogger $root
LoggerLevel $threshold
Method Summary
LoggerHierarchy __construct (LoggerRoot $root)
void clear ()
boolean exists (string $name)
array getCurrentLoggers ()
Logger getLogger (string $name)
LoggerRendererMap getRendererMap ()
LoggerRoot getRootLogger ()
LoggerLevel getThreshold ()
boolean isDisabled (LoggerLevel $level)
void printHierarchy ()
void resetConfiguration ()
void setThreshold (LoggerLevel $threshold, LoggerLevel $l)
void shutdown ()
Variables
mixed $loggers = array() (line 53)

Array holding all Logger instances.

- access: protected

LoggerRendererMap $rendererMap (line 65)

The logger renderer map.

- access: protected

RootLogger $root (line 59)

The root logger.

- access: protected

LoggerLevel $threshold (line 72)

Main level threshold. Events with lower level will not be logged by any logger, regardless of it's configuration.

- access: protected

Methods
Constructor __construct (line 78)

Creates a new logger hierarchy.

- access: public

LoggerHierarchy __construct (LoggerRoot $root)

- LoggerRoot $root: The root logger.

clear (line 87)

Clears all loggers.

- access: public

void clear ()
exists (line 96)

Check if the named logger exists in the hierarchy.

- access: public

boolean exists (string $name)

- string $name

getCurrentLoggers (line 104)

Returns all the currently defined loggers in this hierarchy as an array.

- access: public

array getCurrentLoggers ()
getLogger (line 114)

Returns a named logger instance logger. If it doesn't exist, one is created.

- return: Logger instance.
- access: public

Logger getLogger (string $name)

- string $name: Logger name

getRendererMap (line 151)

Returns the logger renderer map.

- access: public

LoggerRendererMap getRendererMap ()
getRootLogger (line 159)

Returns the root logger.

- access: public

LoggerRoot getRootLogger ()
getThreshold (line 167)

Returns the main threshold level.

- access: public

LoggerLevel getThreshold ()
isDisabled (line 176)

Returns true if the hierarchy is disabled for given log level and false otherwise.

- access: public

boolean isDisabled (LoggerLevel $level)

- LoggerLevel $level

printHierarchy (line 241)

Prints the current Logger hierarchy tree. Useful for debugging.

- access: public

void printHierarchy ()
resetConfiguration (line 194)

Reset all values contained in this hierarchy instance to their default.

This removes all appenders from all loggers, sets the level of all non-root loggers to null, sets their additivity flag to true and sets the level of the root logger to LOGGER_LEVEL_DEBUG.

<p>Existing loggers are not removed. They are just reset.

<p>This method should be used sparingly and with care as it will block all logging until it is completed.</p>

- access: public

void resetConfiguration ()
setThreshold (line 215)

Sets the main threshold level.

- access: public

void setThreshold (LoggerLevel $threshold, LoggerLevel $l)

- LoggerLevel $l
- LoggerLevel $threshold

shutdown (line 230)

Shutting down a hierarchy will safely close and remove all appenders in all loggers including the root logger.

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.

- todo: Check if the last paragraph is correct.
- access: public

void shutdown ()

Documentation generated on Wed, 12 Nov 2025 18:40:33 +0900 by phpDocumentor 1.4.4