From: Duncan C. <dca...@bc...> - 2002-11-30 23:05:51
|
On 2002-11-30 Kevin Goess <ke...@go...> wrote: >I finally got a few minutes to think about log4perl today, and was >looking at my TODO list in the changes file: > > * Bug: If the *same* appender is being attached to several loggers, > appender inheritance doesn't work as expected: Even if the > appender appears twice in the inheritance tree, it's only executed >once. > But it actually needs to be run twice to match log4j. > >For our behavior (attached perl) to match the log4j behavior (attached >java) on the (attached config), I would have to make the change >(attached diff). > >The only unit tests it messes with is 012Deeper.t, which is where it >would be expected. So this would change the behavior of our libraries, >in that if you have an appender attached to plant and also to >plant.tree.leaf, a log message to plant.tree.leaf or below will fire the >appender twice, currently it only does it once (I believe that behavior >seemed more appropriate at the time). > >Any comments before I make the change to bring us into conformity with >log4j? I've been trying to understand why firing the appender twice is either a good thing or not a good thing. In your example, I wonder what the user is trying to achieve by having the appender attached to both plant and plant.tree.leaf? Firing all appenders, regardless of number of occurences sounds simple, but equally why would one want a log message to appear multiple times in the same appender? Do you know what the original log4j rationale was? >RCS file: /cvsroot/log4perl/Log-Log4perl/lib/Log/Log4perl/Logger.pm,v >retrieving revision 1.39 >diff -u -r1.39 Logger.pm >--- lib/Log/Log4perl/Logger.pm 18 Nov 2002 05:34:47 -0000 1.39 >+++ lib/Log/Log4perl/Logger.pm 30 Nov 2002 00:09:31 -0000 >@@ -126,8 +126,9 @@ > > foreach my $appender_name (@{$logger->{appender_names}}){ > >- #only one message per appender, please >- next if $seen{$appender_name} ++; >+ #actually, log4j behavior the appender should >+ #fire each time it's called >+ #next if $seen{$appender_name} ++; > > push (@appenders, > [$appender_name, > The %seen hash can be removed entirely. Is it usual to comment out code rather than remove it? Regards, Duncan Cameron |