Welcome to the Log::Log4perl recipe of the week. Today:
============================================================
Log::Log4perl Recipe of the Week (#12):
How can I configure Log::Log4perl to send me email if
something happens?
============================================================
Some incidents require immediate action. You can't wait
until someone checks the log files, you need to get notified
on your pager right away.
The easiest way to do that is by using the
"Log::Dispatch::Email::MailSend" module as an appender. It
comes with the "Log::Dispatch" bundle and allows you to
specify recipient and subject of outgoing emails in the
Log4perl configuration file:
log4perl.category = FATAL, Mailer
log4perl.appender.Mailer = Log::Dispatch::Email::MailSend
log4perl.appender.Mailer.to = dr...@pa...
log4perl.appender.Mailer.subject = Something's broken!
log4perl.appender.Mailer.layout = SimpleLayout
The message of every log incident this appender gets will
then be forwarded to the given email address. Check the
"Log::Dispatch::Email::MailSend" documentation for details.
And please make sure there's not a flood of email messages
sent out by your application, filling up the receipient's
inbox.
Have fun! Until next week.
-- Mike
###################################
# Mike Schilli #
# log...@pe... #
# http://perlmeister.com #
# http://log4perl.sourceforge.net #
###################################
|