log4perl-devel: I am working on a module that incorporates stealth logging. I've used logwarn() in place of warn() throughout.
When I enable a logger in a script that use's the module, I see warning messages both on the terminal and in the log destination. But, when there is no logger enabled, I don't see any warning messages on the terminal. I was expecting logwarn() would always output the warning message to the terminal, and additionally output the warning message to the log destination if logging is enabled. Apparently, not. As an aside, logdie() appears to work as expected. I see that Log::Log4perl is now version 1.42 on CPAN. I'm on Debian Stable (Wheezy), which has version 1.29. I'd rather not upgrade via 'cpan', as I've found that circumventing Apt and the Debian release process leads to problems. I don't see liblog-log4perl-perl on Debian Backports. Any suggestions? TIA, David 2013-11-04 23:08:03 dpchrist@p43200 ~/sandbox/perl $ cat Log-Log4perl-logwarn.pl #!/usr/bin/perl use strict; use warnings; use Log::Log4perl qw(:easy); warn "first warning"; my $logger = Log::Log4perl->get_logger(); $logger->logwarn("second warning"); Log::Log4perl->easy_init($WARN); warn "third warning"; $logger->logwarn("fourth warning"); 2013-11-04 23:08:08 dpchrist@p43200 ~/sandbox/perl $ perl Log-Log4perl-logwarn.pl first warning at Log-Log4perl-logwarn.pl line 5. third warning at Log-Log4perl-logwarn.pl line 9. 2013/11/04 23:08:12 fourth warning fourth warning at Log-Log4perl-logwarn.pl line 10 2013-11-04 23:08:12 dpchrist@p43200 ~/sandbox/perl $ cat Log-Log4perl-logdie.pl #!/usr/bin/perl use strict; use warnings; use Log::Log4perl qw(:easy); my $logger = Log::Log4perl->get_logger(); $logger->logdie("bye"); 2013-11-04 23:08:18 dpchrist@p43200 ~/sandbox/perl $ perl Log-Log4perl-logdie.pl bye at Log-Log4perl-logdie.pl line 6 2013-11-04 23:08:23 dpchrist@p43200 ~/sandbox/perl $ cat Log-Log4perl-logdie2.pl #!/usr/bin/perl use strict; use warnings; use Log::Log4perl qw(:easy); Log::Log4perl->easy_init($WARN); my $logger = Log::Log4perl->get_logger(); $logger->logdie("bye"); 2013-11-04 23:08:31 dpchrist@p43200 ~/sandbox/perl $ perl Log-Log4perl-logdie2.pl 2013/11/04 23:08:34 bye bye at Log-Log4perl-logdie2.pl line 7 2013-11-04 23:08:34 dpchrist@p43200 ~/sandbox/perl $ perl -MLog::Log4perl -e 'print $Log::Log4perl::VERSION, "\n"' 1.29 2013-11-04 23:08:45 dpchrist@p43200 ~/sandbox/perl $ perl --version This is perl 5, version 14, subversion 2 (v5.14.2) built for i486-linux-gnu-thread-multi-64int (with 88 registered patches, see perl -V for more detail) Copyright 1987-2011, Larry Wall 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. 2013-11-04 23:08:55 dpchrist@p43200 ~/sandbox/perl $ cat /etc/debian_version 7.2 ------------------------------------------------------------------------------ November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk _______________________________________________ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel