tangent has asked for the wisdom of the Perl Monks concerning the following question:
I started using Log4perl some time ago and it is the bees knees, though I only access its most basic functionality. I use it in a cron job that goes something like this:
The problem is that this spews out a large amount of log messages from Net::SMTP (including the entire contents of the email) though when I look at the source of that module I can't find any references to Log4perl or any of its directives. I am guessing that one of the Email::Stuffer modules might be causing it. At the moment I use this workaround:use Log::Log4perl qw(:easy); Log::Log4perl->easy_init( { level => $INFO, file => $logfile } ); INFO "Start process..."; # lots of stuff here my $sender = Email::Stuffer->new; set_transport($sender); # set up SMTP # construct email here, then my $sent = $sender->send; if ( $sent ) { INFO "Email sent..."; } # ...
This suppresses the Net::SMTP messages but I am wondering why my script is controlling this output, and if there is another way to deal with it.Log::Log4perl->easy_init( { level => $ERROR, file => $logfile } ); my $sender = Email::Stuffer->new; # etc my $sent = $sender->send; Log::Log4perl->easy_init( { level => $INFO, file => $logfile } );
Update: As is often the case I think I have found the answer just after asking the question - when I set up the SMTP transport I have debug => 1 so maybe Log4perl is appropriating the debug messages. Will test later.
|
|---|