Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Sorry -- I assume that this was pretty straightforward. here's the configuration file, edited for security ..

1 # Configuration file for work script 2 3 log4perl.logger = INFO, Screen, Logfile, Mailer 4 5 log4perl.appender.Screen = Log::Log4perl::Appender::Scree +n 6 log4perl.appender.Screen.stderr = 0 7 log4perl.appender.Screen.layout = Log::Log4perl::Layout::Pattern +Layout 8 log4perl.appender.Screen.layout.ConversionPattern = %d %p : %m%n 9 log4perl.appender.Screen.Threshold = INFO 10 11 log4perl.appender.Logfile = Log::Log4perl::Appender::File 12 log4perl.appender.Logfile.filename = work_script.log 13 log4perl.appender.Logfile.mode = append 14 log4perl.appender.Logfile.layout = Log::Log4perl::Layout::Patter +nLayout 15 log4perl.appender.Logfile.layout.ConversionPattern = %d %p : %m%n 16 17 log4perl.appender.Mailer = XYZ::LogDispatchEmailSender 18 log4perl.appender.Mailer.to = someguy@example.com 19 # 20 log4perl.appender.Mailer.subject = XYZ Topic 21 log4perl.appender.Mailer.layout = Log::Log4perl::Layout::PatternL +ayout 22 log4perl.appender.Mailer.layout.ConversionPattern = %d %p : %m%n 23 log4perl.appender.Mailer.Threshold = INFO
The module I use to actually send an E-Mail is here:
1 package XYZ::LogDispatchEmailSender; 2 3 # 2018-0515: From the MetaCPAN page 4 # https://metacpan.org/pod/Log::Dispatch::Email, here's a local m +odule that 5 # will send E-Mail. .. 6 # .. 7 8 use Log::Dispatch::Email; 9 10 use base qw( Log::Dispatch::Email ); 11 12 use Email::Simple; 13 use Email::Sender::Simple qw(sendmail); 14 use Email::Sender::Transport::SMTP qw(); 15 use Try::Tiny; 16 17 use lib ..; 18 19 use XYZEMail; 20 21 sub send_email 22 { 23 my $self = shift; 24 my %p = @_; 25 26 my $message = Email::Simple->create( 27 header => [ 28 To => join(', ',@{ $self->{'to'} }), 29 From => 'anotherguy@example.com', 30 Subject => $self->{'subject'}, 31 ], 32 body => $p{ message }, 33 ); 34 35 try { 36 sendmail( 37 $message, 38 { 39 from => 'anotherguy@example.com', 40 transport => Email::Sender::Transport::SMTP->new( 41 { 42 host => $XYZEMail::Host, 43 port => $XYZEMail::Port, 44 sasl_username => $XYZEMail::User, 45 sasl_password => $XYZEMail::Password, 46 ssl => 'starttls', 47 } 48 ) 49 } 50 ); 51 } 52 catch { 53 warn "sending failed: $_"; 54 }; 55 } 56 57 1;

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.


In reply to Re^2: Possible scoping issue with Log::Log4perl logger by talexb
in thread Possible scoping issue with Log::Log4perl logger by talexb

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 goofing around in the Monastery: (4)
As of 2024-05-29 06:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found