Skip Menu |

This queue is for tickets about the Log-Log4perl CPAN distribution.

Report information
The Basics
Id: 46446
Status: resolved
Priority: 0/
Queue: Log-Log4perl

People
Owner: Nobody in particular
Requestors: joerg [...] joergmeltzer.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.23
Fixed in: (no value)



Subject: Log::Dispatch integration broken
# The following prints nothing in Log::Log4perl 1.23 perl -MLog::Log4perl=get_logger -e " $l=get_logger; $l->add_appender(Log::Log4perl::Appender->new('Log::Dispatch::Screen')); $l->info('foo')" # This is probably why it prints nothing perl -MB::Deparse -MLog::Log4perl=get_logger -e " $l=get_logger; $d=B::Deparse->new; $l->add_appender(Log::Log4perl::Appender->new('Log::Dispatch::Screen')); print $d->coderef2text($l->{INFO}) " { package Log::Log4perl::Logger; use warnings; use strict 'refs'; '???'; return undef; } # When I fallback to 1.20 it works correctly. perl -MLog::Log4perl=get_logger -e "$l=get_logger; $l->add_appender(Log::Log4perl::Appender->new('Log::Dispatch::Screen')); $l->info('foo')" INFO - foo perl -MLog::Dispatch -e "print Log::Dispatch->VERSION" 2.22 perl -v This is perl, v5.10.0 built for MSWin32-x86-multi-thread (with 5 registered patches, see perl -V for more detail) Copyright 1987-2007, Larry Wall Binary build 1004 [287188] provided by ActiveState http://www.ActiveState.com Built Sep 3 2008 13:16:37 Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
On Thu May 28 16:22:32 2009, JMELTZER wrote: Show quoted text
> # The following prints nothing in Log::Log4perl 1.23
I don't see how this is supposed to print something: You're using an uninitialized Log4perl logger, which is supposed to block everything. If you add a level() call to initialize the logger, then it's supposed to print something: use Log::Log4perl qw(get_logger :levels); use Log::Dispatch::Screen; my $l=get_logger(); $l->level( $DEBUG ); $l->add_appender(Log::Log4perl::Appender->new( "Log::Dispatch::Screen")); $l->info('foo');
Thank you, I just didn't dig deep enough in the documentation. By some fortune it was working until L::L4p 1.23. I was confused, that even though I specified min_level for all my Log::Dispatch appenders nothing was printed out. Would it be possible to set $log->level($DEBUG) by default and let users override it if they want? Regards, Jörg On Do. 28. Mai 2009, 17:48:21, MSCHILLI wrote: Show quoted text
> On Thu May 28 16:22:32 2009, JMELTZER wrote:
> > # The following prints nothing in Log::Log4perl 1.23
> > I don't see how this is supposed to print something: You're using an > uninitialized Log4perl logger, which is supposed to block everything. > > If you add a level() call to initialize the logger, then it's supposed > to print something: > > use Log::Log4perl qw(get_logger :levels); > use Log::Dispatch::Screen; > > my $l=get_logger(); > > $l->level( $DEBUG ); > > $l->add_appender(Log::Log4perl::Appender->new( > "Log::Dispatch::Screen")); > > $l->info('foo');
Subject: Re: [rt.cpan.org #46446] Log::Dispatch integration broken
Date: Sat, 8 Aug 2009 13:23:24 -0700 (PDT)
To: Joerg Meltzer via RT <bug-Log-Log4perl [...] rt.cpan.org>
From: Mike Schilli <m [...] perlmeister.com>
On Sat, 8 Aug 2009, Joerg Meltzer via RT wrote: Show quoted text
> Would it be possible to set $log->level($DEBUG) by default and let > users override it if they want?
By default, Log4perl is supposed to be invisible -- if you'd set the default level to DEBUG, that would no longer be the case. -- Mike Mike Schilli m@perlmeister.com
Agreed "debug" would be a too low default loglevel (leading to bad practices in development). But somehow I feel for production code there should be a default log level. $l->fatal('rocket is missing fuel') should log something wether or not you forgot $l->level($level). It surprised me, when this after a rework of L::L4P suddenly stopped working. Anyway my mistake is hereby documented, If you don't like any default level I am fine with it. Regards, Joerg On Sa. 08. Aug. 2009, 16:24:33, m@perlmeister.com wrote: Show quoted text
> On Sat, 8 Aug 2009, Joerg Meltzer via RT wrote: >
> > Would it be possible to set $log->level($DEBUG) by default and let > > users override it if they want?
> > By default, Log4perl is supposed to be invisible -- if you'd set the > default level to DEBUG, that would no longer be the case. > > -- Mike > > Mike Schilli > m@perlmeister.com
On Wed Aug 19 01:58:46 2009, JMELTZER wrote: Show quoted text
> Agreed "debug" would be a too low default loglevel (leading to bad > practices in development).
That's not the point, though. It's important to understand that a logger, by itself, is by default off. What enables the logger (hence assigns it a level) is the Log4perl configuration file. If you don't initialize Log4perl via a configuration file (or other means), then all loggers are by default off. This is very important, because a script foo.pl can use module Bar.pm without even knowing about its Log4perl-enabledness. If it doesn't call Log4perl's init function, Bar.pm will suppress anything Log4perl-related. There was a bug in 1.20 that exhibited the behavior you're describing, but that was an anomaly, not the documented functionality. I'm sorry if this bug has caused incorrect scripts to work, but the way it's been fixed is the correct way -- so please don't rely on the broken behavior. -- Mike
Marked resolved.