Hi Ionel,
this is not a fault, this is the default and wanted behaviour of
log4j. A short extract from the (short) manual:
>The addAppender method adds an appender to a given logger. Each
>enabled logging request for a given logger will be forwarded to all
>the appenders in that logger as well as the appenders higher in the
>hierarchy. In other words, appenders are inherited additively from the
>logger hierarchy. For example, if a console appender is added to the
>root logger, then all enabled logging requests will at least print on
>the console. If in addition a file appender is added to a logger, say
>C, then enabled logging requests for C and C's children will print on
>a file and on the console. It is possible to override this default
>behavior so that appender accumulation is no longer additive by
>setting the additivity flag to false.
I had exactly the same problems last week, but after re-reading the
manual I found the above passage *g*
So if you want class B only to log to the dedicated logger you have to
add a line like this:
log4j.appender.classB.additivity = false
Cheers,
Christian
Monday, January 19, 2004, 8:54:36 PM,:
IG> Hi,
IG> I have the following problem : say I have two classes
IG> :
IG> abstract class A { Logger log =
IG> Logger.getLogger(this.getClass(); }
IG> class B extends A { log.debug("foo"); }
IG> class C extends A { log.debug("bar"); }
IG> I declared the RootLogger as a file logger to a file
IG> named "main.log"
IG> When I look at the main.log file, I have the log from
IG> both B and C, with both information about the class
IG> which made the log.
IG> Now, if I declare another logger, especialy for the B
IG> class, I can see B's log messages in both the root
IG> logger and its dedicated logger.
IG> C's log appears only in the main logger (as expected)
IG> Problem is : for the B class, why does the root logger
IG> gets the message too ?
IG> Is it a side-effect because I declare the logger in an
IG> abstract superclass and I declared the custom logger
IG> upon the B class ?
IG> Is there a way to tell "if I have a dedicated logger
IG> for a class, use it but do not log to the root logger
IG> ?"
IG> thanks,
IG> ionel
IG> _________________________________________________________________
IG> Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en fran�ais !
IG> Yahoo! Mail : http://fr.mail.yahoo.com
IG> ---------------------------------------------------------------------
IG> To unsubscribe, e-mail: [EMAIL PROTECTED]
IG> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]