From: David C. <dpc...@ho...> - 2013-11-05 18:02:45
|
On 11/04/2013 11:18 PM, David Christensen wrote: > 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. I found a work-around -- write a wrapper that calls warn() and $logger->warn() instead. HTH, David 2013-11-05 10:01:04 dpchrist@p43200 ~/sandbox/perl $ cat Log-Log4perl-warn.pl #!/usr/bin/perl use strict; use warnings; use Log::Log4perl qw(:easy); sub mylogwarn { my $logger = Log::Log4perl->get_logger(); warn @_; $logger->warn(@_); } mylogwarn "first warning"; Log::Log4perl->easy_init($WARN); mylogwarn "second warning"; 2013-11-05 10:01:10 dpchrist@p43200 ~/sandbox/perl $ perl Log-Log4perl-warn.pl first warning at Log-Log4perl-warn.pl line 7. second warning at Log-Log4perl-warn.pl line 7. 2013/11/05 10:01:13 second warning |