Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( #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":



  • 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, 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, 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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (7)
    As of 2020-11-24 23:39 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?