Class LoggerAppenderMail

Description

Appends log events to mail using php function http://www.php.net/mail.

The appender sends all log events at once after the request has been finsished and the appender is beeing closed.

Configurable parameters for this appender:

  • layout - Sets the layout class for this appender (required)
  • to - Sets the recipient of the mail (required)
  • from - Sets the sender of the mail (optional)
  • subject - Sets the subject of the mail (optional)
An example:

  1. require_once dirname(__FILE__).'/../../main/php/Logger.php';
  2.  
  3. Logger::configure(dirname(__FILE__).'/../resources/appender_mail.properties');
  4. $logger Logger::getRootLogger();
  5. $logger->fatal("Some critical message!");
  6. $logger->fatal("Some more critical message!");

  1. log4php.appender.email = LoggerAppenderMail
  2. log4php.appender.email.layout = LoggerLayoutTTCC
  3. log4php.appender.email.from = someone@example.com
  4. log4php.appender.email.to = root@localhost
  5. log4php.appender.email.subject = Log4php test
  6. log4php.rootLogger = FATAL, email

The above will output something like:

      Date: Tue,  8 Sep 2009 21:51:04 +0200 (CEST)
      From: someone@example.com
      To: root@localhost
      Subject: Log4php test

      Tue Sep  8 21:51:04 2009,120 [5485] FATAL root - Some critical message!
      Tue Sep  8 21:51:06 2009,120 [5485] FATAL root - Some more critical message!

  • version: $Revision: 1213283 $

Located in /appenders/LoggerAppenderMail.php (line 55)

LoggerConfigurable
   |
   --LoggerAppender
      |
      --LoggerAppenderMail
Variable Summary
string $body
indiciates $dry
string $from
string $subject
string $to
Method Summary
void append (LoggerLoggingEvent $event)
void close ()
void setDry ( $dry)
void setFrom ( $from)
void setSubject ( $subject)
void setTo ( $to)
Variables
string $body = '' (line 70)
  • var: used to create mail body
  • access: protected
indiciates $dry = false (line 67)
  • var: if this appender should run in dry mode
  • access: protected
string $from = null (line 58)
  • var: 'from' field
  • access: protected
string $subject = 'Log4php Report' (line 61)
  • var: 'subject' field
  • access: protected
string $to = null (line 64)
  • var: 'to' field
  • access: protected

Inherited Variables

Inherited from LoggerAppender

LoggerAppender::$closed
LoggerAppender::$filter
LoggerAppender::$layout
LoggerAppender::$name
LoggerAppender::$requiresLayout
LoggerAppender::$threshold
Methods

Documentation generated on Sat, 18 Feb 2012 22:32:22 +0000 by phpDocumentor 1.4.3