logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bender Heri" <HBen...@Ergonomics.ch>
Subject RE: Log4J Help requested
Date Wed, 06 Jul 2005 16:01:56 GMT
see comment inline

> -----Original Message-----
> From: Balaji Saranathan [mailto:balaji.saranathan@wipro.com]
> Sent: Wednesday, July 06, 2005 5:21 PM
> To: 'Log4J Users List'; balaji.saranathan@wipro.com; 'Bradley, Todd'
> Subject: RE: Log4J Help requested
> 
> 
> 
> I was using the getAllAppenders on the logger that was created with
> classname. It returns an empty enumeration. The Root
> logger.getAllAppenders lists my appender I added in the configuration.
> Is it not true that the appenders are inherited from the rootlogger
> unless explictiyl configured?

Not exactly. Log4j creates a hierarchy of named loggers, similar to the package hierarchy,
using the dot as node separator.

If your logger which you have instantiated by using the classname is not configured exactly
with the same classname, the log4j will create a new logger without any appenders, but with
the flag inherited=true, and place this logger somewhere in the hierarchy below root looger.
If you make a log statement against this logger, it will serve all appenders defined within
itself (in this case none) and also all appenders attached to loggers higher in the hierarchy,
until it reaches the root logger or a logger with inerited=false.
So, if you want to access the configured appenders by code you have to create a logger using
exactly the same name like in config file. In your case it's the root logger which you get
by calling Logger.getRootLogger().

Clear?

Heri

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message