Log::Log4perl::Appender::SMTP - Send logs by email
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!");
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.
The email address of the sender.
The email address of the recipient. You can put several addresses separated by a comma.
The subject of the email. Newlines and tabs are forbidden here.
They all start with an upper-cased letter. The most common are Host, Hello, Port, Timeout and Debug. See Net::SMTP for more.
The following Log4perl configuration file allows you to send an email on each use of $log->fatal().
$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
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.
bug-log-log4perl-appender-smtp at rt.cpan.org
Olivier Duclos, <odc at cpan.org>
<odc at cpan.org>
Copyright 2014 Olivier Duclos.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Log::Log4perl, Net::SMTP
To install Log::Log4perl::Appender::SMTP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Log4perl::Appender::SMTP
CPAN shell
perl -MCPAN -e shell install Log::Log4perl::Appender::SMTP
For more information on module installation, please visit the detailed CPAN module installation guide.