Venerable Monks,

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:

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..."; } # ...
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:
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 } );
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.

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.


In reply to Log::Log4perl and Net::SMTP by tangent

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.