On Sun, 10 Aug 2008, Ben Tilly wrote: > While it is not logically necessary to ever have it, see > http://www.perlmonks.org/index.pl?node_id=703501 for an example of > someone trying to configure things so that a trace goes somewhere, he > tried to set > log4perl.appender.StdOut.min_level=trace
Hi Ben, thanks for the patch. It would need to be applied to Log::Dispatch, not Log4perl, though. Log::Dispatch is a different project. It works well with Log4perl, and we use its appenders so that we don't have to re-invent the wheel. It's managed by Dave Rolsky: http://search.cpan.org/~drolsky/Log-Dispatch/ I'm not sure if Dave is going add another level to Log::Dispatch, but you can try :). min_level is Log::Dispatch-specific, but the same thing can be done natively in Log4perl with an appender threshold: log4perl.appender.Screen1 = Log::Log4perl::Appender::Screen log4perl.appender.Screen1.layout = SimpleLayout log4perl.appender.Screen1.Threshold = ERROR or if you want to define a range, use a LevelRange filter: http://log4perl.sourceforge.net/d/Log/Log4perl/Filter/LevelRange.html Here's how to apply filters to Log4perl's appenders: http://log4perl.sourceforge.net/d/Log/Log4perl/Filter.html And, just so you know, Log4perl has its own screen and file appenders, Log::Log4perl::Appender::Screen and Log::Log4perl::Appender::File. Especially the file appender has a lot more options than its Log::Dispatch counterpart. Use the one that suits your needs. :) -- Mike Mike Schilli [EMAIL PROTECTED] > > in the log file only to find that > > trace is not a valid Log::Dispatch log level at > /Library/Perl/5.8.8/Log/Log4perl/Appender.pm line 77 > > Which is highly confusing because the documentation for Log::Log4perl > says very clearly that trace *is* a valid logging level. > > I told the questioner how to make it work, but still I think the fix > should be made to avoid useless confusion. > > And yes, I looked at the code, and I'm aware that there is no > non-hacky way to do it. Still it can be done. Here is a patch to do > it. > > --- Dispatch.pm 2008-08-10 20:43:32.000000000 -0700 > +++ Dispatch.pm.fix 2008-08-10 20:39:22.000000000 -0700 > @@ -9,14 +9,14 @@ > > use Carp (); > > -our $VERSION = '2.21'; > +our $VERSION = '2.22'; > our %LEVELS; > > > BEGIN > { > no strict 'refs'; > - foreach my $l ( qw( debug info notice warning err error crit > critical alert emerg emergency ) ) > + foreach my $l ( qw( trace debug info notice warning err error > crit critical alert emerg emergency ) ) > { > *{$l} = sub { my $self = shift; > $self->log( level => $l, message => "@_" ); }; > > > --- Dispatch/Output.pm 2008-08-10 20:43:54.000000000 -0700 > +++ Dispatch/Output.pm.fix 2008-08-10 20:43:48.000000000 -0700 > @@ -12,7 +12,7 @@ > > use Carp (); > > -our $VERSION = '1.26'; > +our $VERSION = '1.27'; > > > sub new > @@ -52,13 +52,17 @@ > } ); > > # Map the names to numbers so they can be compared. > - $self->{level_names} = [ qw( debug info notice warning error > critical alert emergency ) ]; > + # We would like trace to be first, but we can't change the historical > + # numbers for backwards compatibility reasons. > + $self->{level_names} = [ qw( debug info notice warning error > critical alert emergency trace ) ]; > > my $x = 0; > $self->{level_numbers} = { ( map { $_ => $x++ } @{ > $self->{level_names} } ), > err => 4, > crit => 5, > - emerg => 7 }; > + emerg => 7, > + trace => -1 }; > + die $self->{level_numbers}{trace}; > > $self->{name} = $p{name}; > > @@ -70,7 +74,7 @@ > $self->{max_level} = > ( exists $p{max_level} ? > $self->_level_as_number($p{max_level}) : > - $#{ $self->{level_names} } > + $#{ $self->{level_names} } - 1 # Skip trace > ); > > die "Invalid level specified for max_level" unless defined > $self->{max_level}; > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > log4perl-devel mailing list > log4perl-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/log4perl-devel > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel