cah has asked for the wisdom of the Perl Monks concerning the following question:
Update, I didn't realize divide by zero caused a die... Adding the following code resolved my issue:use strict; use warnings; use FindBin; use lib "$FindBin::Bin/../lib"; use Log::Log4perl qw(get_logger); # Initialize logging behaviour BEGIN { my $conf = q( log4perl.logger = DEBUG, FileApp log4perl.appender.FileApp = Log::Log4perl::Ap +pender::File log4perl.appender.FileApp.filename = test.log log4perl.appender.FileApp.layout = PatternLayout ); Log::Log4perl->init( \$conf ); $SIG{__WARN__} = sub { my $logger = get_logger(); local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_dep +th + 1; $logger->warn("WARN @_"); }; } my $logger = get_logger(); $logger->error("Oh my, an error!"); my $foo = 100; my $foo = 44; my $bar = 0; 1/0;
$SIG{__DIE__} = sub { my $logger = get_logger(); local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_dep +th + 1; $logger->fatal("DIE @_"); };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: log::log4perl capture warnings
by jeffa (Bishop) on Apr 29, 2015 at 18:32 UTC | |
by cah (Initiate) on Apr 29, 2015 at 19:25 UTC | |
|
Re: log::log4perl capture warnings
by Laurent_R (Canon) on Apr 29, 2015 at 20:16 UTC | |
|
Re: log::log4perl capture warnings
by edimusrex (Monk) on Apr 29, 2015 at 18:28 UTC |