The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Log::Log4perl::Appender::SMTP - Send logs by email

SYNOPSIS

  use Log::Log4perl::Appender::SMTP;

  my $app = Log::Log4perl::Appender::SMTP->new(
    Host    => "localhost",
    Hello   => "localhost.localdomain",
    Timeout => 2,
    Debug   => 0,
    from    => "app@company.com",
    to      => "bugs@company.com"
  );

  $app->log(message => "You need to come to the office now!");

DESCRIPTION

This appender is a very thin layer over the Net::SMTP module. It allows you to easily send important log messages by email, to one or several recipients. All of the Net::SMTP attributes are supported.

OPTIONS

from

The email address of the sender.

to

The email address of the recipient. You can put several addresses separated by a comma.

subject

The subject of the email. Newlines and tabs are forbidden here.

all of the Net::SMTP options

They all start with an upper-cased letter. The most common are Host, Hello, Port, Timeout and Debug. See Net::SMTP for more.

EXAMPLE

The following Log4perl configuration file allows you to send an email on each use of $log->fatal().

  # Filter for FATAL
  log4perl.filter.MatchFatal = Log::Log4perl::Filter::LevelMatch
  log4perl.filter.MatchFatal.LevelToMatch  = FATAL
  log4perl.filter.MatchFatal.AcceptOnMatch = true

  # Email Appender for FATAL
  log4perl.appender.mailFatal = Log::Log4perl::Appender::SMTP
  log4perl.appender.mailFatal.to = webmaster@company.com
  log4perl.appender.mailFatal.Host = smtp.company.com
  log4perl.appender.mailFatal.subject = Fatal error on Foo!
  log4perl.appender.mailFatal.layout = Log::Log4perl::Layout::PatternLayout
  log4perl.appender.mailFatal.layout.ConversionPattern = %d F{1} %L %p> %m%n
  log4perl.appender.mailFatal.Filter = MatchFatal

BUGS

Please report any bugs or feature requests to bug-log-log4perl-appender-smtp at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Log-Log4perl-Appender-SMTP. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

AUTHOR

Olivier Duclos, <odc at cpan.org>

LICENSE

Copyright 2014 Olivier Duclos.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Log::Log4perl, Net::SMTP