in reply to log4perl run from within another package not firing messages sent through email

Found the problem with some help from the FAQ at http://search.cpan.org/dist/Log-Log4perl-1.30/lib/Log/Log4perl/FAQ.pm#How_can_I_configure_Log::Log4perl_to_send_me_email_if_something_happens

Apparently, there is some buffering going on so emails do not get sent out immediately until some threshold for the number of messages generated is reached. Though it's still a mystery to me as to why emails are sent immediately when the code is in the main package.

So here is the code that works with the buffered property set to 0:

my $appender_email = Log::Log4perl::Appender->new( "Log::Dispatch::Email::SSMTP", threshold => "INFO", to => 'me@mymail.com', buffered => 0, subject => 'Perl script message' );

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon";
$nysus = $PM . $MCF;
Click here if you love Perl Monks

  • Comment on Re: log4perl run from within another package not firing messages sent through email
  • Download Code

Replies are listed 'Best First'.
Re^2: log4perl run from within another package not firing messages sent through email
by nysus (Parson) on Dec 03, 2015 at 20:00 UTC
    Does anyone know why I needed the "buffered" property when I run this code from inside a package and not when run from within "main"?

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon";
    $nysus = $PM . $MCF;
    Click here if you love Perl Monks

      Have you tried examining your Appender object with Data::Dumper or similar to see what the value of the buffered attribute is when you create it from within your main script? At least if you knew whether it was being similarly set to '0' you could narrow your search to 'why?' ...

      The way forward always starts with a minimal test.