Hello Monks

I'm trying to use Log4perl to send email alerts. Gone over the log4perl docs extensively.

I'm using Mail::Sender rather than Mail::Send -- I'm not sure why, but Mail::Send doesn't work for me so I'm trying Mail::Sender.

Log::Dispatch::Email::MailSender appears to be installed ok:

[414][/cygdrive/r/micmac]$ cpan install Log::Dispatch::Email::MailSend +er CPAN: Storable loaded ok (v2.27) Going to read '/home/micmac/.cpan/Metadata' Database was generated on Thu, 26 Jun 2014 20:41:02 GMT CPAN: Module::CoreList loaded ok (v2.49_02) Log::Dispatch::Email::MailSender is up to date (2.41).
Ok so I run my example:
[415][/cygdrive/r/micmac]$ ./lw_ex1.pl ERROR: can't load appenderclass 'Log::Dispatch::Email::MailSender' Can't locate Mail/Sender.pm in @INC (@INC contains: /usr/lib/perl5/sit +e_perl/5.14/i686-cygwin-threads-64int /usr/lib/perl5/site_perl/5.14 / +usr/lib/perl5/vendor_perl/5.14/i686-cygwin-threads-64int /usr/lib/per +l5/vendor_perl/5.14 /usr/lib/perl5/5.14/i686-cygwin-threads-64int /us +r/lib/perl5/5.14 /usr/lib/perl5/site_perl/5.10 /usr/lib/perl5/vendor_ +perl/5.10 /usr/lib/perl5/site_perl/5.8 .) at /usr/lib/perl5/site_perl +/5.14/Log/Dispatch/Email/MailSender.pm line 18. BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.14/Log +/Dispatch/Email/MailSender.pm line 18. Compilation failed in require at (eval 24) line 2.
Right it's not there, so why did cpan say it was ok?
[417][/cygdrive/r/davem]$ perl -MLog::Dispatch::Email::MailSender -e 1 Can't locate Mail/Sender.pm in @INC (@INC contains: /usr/lib/perl5/sit +e_perl/5.14/i686-cygwin-threads-64int /usr/lib/perl5/site_perl/5.14 / +usr/lib/perl5/vendor_perl/5.14/i686-cygwin-threads-64int /usr/lib/per +l5/vendor_perl/5.14 /usr/lib/perl5/5.14/i686-cygwin-threads-64int /us +r/lib/perl5/5.14 /usr/lib/perl5/site_perl/5.10 /usr/lib/perl5/vendor_ +perl/5.10 /usr/lib/perl5/site_perl/5.8 .) at /usr/lib/perl5/site_perl +/5.14/Log/Dispatch/Email/MailSender.pm line 18. BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.14/Log +/Dispatch/Email/MailSender.pm line 18. Compilation failed in require. BEGIN failed--compilation aborted.
My log4perl.conf mailer section:

#Mailer log4perl.appender.Mailer=Log::Dispatch::Email::MailSender log4perl.appender.Mailer.from=${Mailer_To} log4perl.appender.Mailer.to=${Mailer_To} log4perl.appender.Mailer.smtp=exchange.mycompany.com log4perl.appender.Mailer.subject=${MailerSubject} log4perl.appender.Mailer.layout=Log::Log4perl::Layout::PatternLayout log4perl.appender.Mailer.layout.ConversionPattern=%d - [CAT:%c %F HOS +T:%H] %p > %m%n log4perl.appender.Mailer.Threshold=WARN log4perl.appender.Mailer.buffered=${Buffered} log4perl.appender.Mailer.Filter=MailFilter

If I switch back to Mail::Send I get this:

422/cygdrive/r/micmac$ ./lw_ex1.pl Cannot close handle to mail program at /usr/lib/perl5/site_perl/5.14/Log/Dispatch/Email/MailSend.pm line 35.

lw_ex1.pl is just a simple script to run it:

#!/usr/bin/perl use strict; use Log::Log4perl qw(get_logger :levels :no_extra_logdie_message); Log::Log4perl::init("log4perl.conf); my $logger = get_logger("example"); $logger->info("START " . basename($0)); $logger->info("la ti da");
Any help most appreciated.

In reply to Log4perl Email appender problem by Anonymous Monk

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.