The logger architecture enables
logger names to be multiple levels so that descendant loggers can
inherit thresholds and appender references from their parent loggers,
therefore omitting the appender reference and threshold in the descendant
logger definition. You separate hierarchical logger names with a period
(.).
For example, suppose
that your logging facility configuration file defines the Admin logger
with an appender reference value of
MyRollingFile
and a threshold of
Info
. A second
logger definition, Admin.MyPgm, specifies the logger name and a threshold
of
Debug
. Because no appender reference
is specified in Admin.MyPgm, the appender reference is inherited from
its parent, the Admin logger. The appender reference
MyRollingFile
logs messages for Admin log events
whose level is INFO or higher, as well as Admin.MyPgm log events whose
level is DEBUG or higher.
These loggers might
be defined using the following logger elements in the logging configuration
file:
<logger name="Admin">
<level value="Info"/>
<appender-ref ref="MyRollingFile"/>
</logger>
<logger name="Admin.MyPgm">
<level value="Debug"/>
</logger>
<root>
<level value="Error"/>
<appender-ref ref="SystemRollingFile">
</root>
If a log event specifies
a hierarchical logger name that does not exist, the logging facility
checks for a parent logger definition. If the parent logger exists,
the log event is processed by the parent logger. If a logger definition
does not exist for the parent, the root logger processes the log event.
Consider the example
logger definitions in this section. If a log event specifies the logger
Admin.Special, the logging facility determines that the logger Admin.Special
does not exist. The logging facility then checks for the Admin logger.
In this case, the Admin logger exists and the log event is processed
by the Admin logger. If the Admin logger was not defined, the root
logger would process the log event.