Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-20 01:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found