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

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

Reply via email to