Hi All, I am trying to use log4perl to send alert emails from my script... I'm not being successful. Here is the code I have for setting up an email logger for perl using Log::Dispatch::Email::MailSendmail:
use Log::Log4perl qw(get_logger :levels); my $log4perl_conf=<<CFG log4perl.rootLogger=INFO, Email log4perl.appender.Email=Log::Dispatch::Email::MailSendmail log4perl.appender.Email.to=me@company.com log4perl.appender.Email.from=me@company.com log4perl.appender.Email.min_level=info log4perl.appender.Email.layout=Log::Log4perl::Layout::PatternLayout log4perl.appender.Email.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:s +s} [%F{1}:%c{1}] %5p> %m%n CFG ; Log::Log4perl::init(\$log4perl_conf); my $logger = Log::Log4perl->get_logger(); $logger->info('Something bad is happening');
I'm not getting a delivered email. However, I know the base Mail::SendMail module delivers an email:
use Mail::Sendmail; # TLRTSRMG-CapacityPlanning@thomson.com %mail = ( To => 'me@company.com', From => 'me@company.com', Message => "Sorry, testing this out for emailing -- please i +gnore", Subject => "DELETE ME: Email Testing" ); sendmail(%mail) or die $Mail::Sendmail::error; print "OK. Log says:\n", $Mail::Sendmail::log;
Any ideas how to get the log4perl appender working? Thanks, Matt

In reply to log4perl and Log::Dispatch::Email::MailSendmail by mpettis

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.