SMTPAppender Class Reference

Inheritance diagram for SMTPAppender:

Inheritance graph
[legend]
Collaboration diagram for SMTPAppender:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SMTPAppender ()
 SMTPAppender (spi::TriggeringEventEvaluatorPtr evaluator)
virtual void setOption (const String &option, const String &value)
virtual void activateOptions ()
virtual void append (const spi::LoggingEventPtr &event)
bool checkEntryConditions ()
virtual void close ()
const String & getTo () const
virtual bool requiresLayout () const
void sendBuffer ()
const String & getCharset () const
const String & getEncoding () const
String getEvaluatorClass ()
const String & getFrom () const
const String & getSubject () const
void setCharset (const String &charset)
void setEncoding (const String &charset)
void setFrom (const String &from)
void setSubject (const String &subject)
void setBufferSize (int bufferSize)
void setSMTPHost (const String &smtpHost)
const String & getSMTPHost () const
void setTo (const String &to)
int getBufferSize () const
void setEvaluatorClass (const String &value)
void setLocationInfo (bool locationInfo)
bool getLocationInfo () const

Detailed Description

Send an e-mail when a specific logging event occurs, typically on errors or fatal errors.

The number of logging events delivered in this e-mail depend on the value of BufferSize option. The SMTPAppender keeps only the last BufferSize logging events in its cyclic buffer. This keeps memory requirements at a reasonable level while still delivering useful application context.


Constructor & Destructor Documentation

SMTPAppender  ) 
 

The default constructor will instantiate the appender with a spi::TriggeringEventEvaluator that will trigger on events with level ERROR or higher.

SMTPAppender spi::TriggeringEventEvaluatorPtr  evaluator  ) 
 

Use evaluator passed as parameter as the spi::TriggeringEventEvaluator for this net::SMTPAppender.


Member Function Documentation

void activateOptions  )  [virtual]
 

Activate the specified options, such as the smtp host, the recipient, from, etc.

Reimplemented from AppenderSkeleton.

void append const spi::LoggingEventPtr event  )  [virtual]
 

Perform SMTPAppender specific appending actions, mainly adding the event to a cyclic buffer and checking if the event triggers an e-mail to be sent.

Implements AppenderSkeleton.

bool checkEntryConditions  ) 
 

This method determines if there is a sense in attempting to append.

It checks whether there is a set output target and also if there is a set layout. If these checks fail, then the boolean value false is returned.

void close  )  [virtual]
 

Release any resources allocated within the appender such as file handles, network connections, etc.

It is a programming error to append to a closed appender.

Implements Appender.

int getBufferSize  )  const [inline]
 

Returns value of the BufferSize option.

const String& getCharset  )  const [inline]
 

Returns value of the Charset option.

const String& getEncoding  )  const [inline]
 

Returns value of the Encoding option.

String getEvaluatorClass  ) 
 

Returns value of the EvaluatorClass option.

const String& getFrom  )  const [inline]
 

Returns value of the From option.

bool getLocationInfo  )  const [inline]
 

Returns value of the LocationInfo option.

const String& getSMTPHost  )  const [inline]
 

Returns value of the SMTPHost option.

const String& getSubject  )  const [inline]
 

Returns value of the Subject option.

const String& getTo  )  const [inline]
 

Returns value of the To option.

virtual bool requiresLayout  )  const [inline, virtual]
 

The SMTPAppender requires a layout.

Implements Appender.

void sendBuffer  ) 
 

Send the contents of the cyclic buffer as an e-mail message.

void setBufferSize int  bufferSize  ) 
 

The BufferSize option takes a positive integer representing the maximum number of logging events to collect in a cyclic buffer. When the BufferSize is reached, oldest events are deleted as new events are added to the buffer. By default the size of the cyclic buffer is 512 events.

void setCharset const String &  charset  )  [inline]
 

The Charset option takes a string value which should be the charset of the mail (us-ascii, iso8859_1, iso8859_2, iso8859_3).

void setEncoding const String &  charset  )  [inline]
 

The Encoding option takes a string value which should be the encoding type of the mail (7bit, 8bit, base64, binary, quoted).

void setEvaluatorClass const String &  value  ) 
 

The EvaluatorClass option takes a string value representing the name of the class implementing the spi::TriggeringEventEvaluator interface. A corresponding object will be instantiated and assigned as the triggering event evaluator for the SMTPAppender.

void setFrom const String &  from  )  [inline]
 

The From option takes a string value which should be a e-mail address of the sender.

void setLocationInfo bool  locationInfo  )  [inline]
 

The LocationInfo option takes a boolean value. By default, it is set to false which means there will be no effort to extract the location information related to the event. As a result, the layout that formats the events as they are sent out in an e-mail is likely to place the wrong location information (if present in the format).

Location information extraction is comparatively very slow and should be avoided unless performance is not a concern.

void setOption const String &  option,
const String &  value
[virtual]
 

Set options

Reimplemented from AppenderSkeleton.

void setSMTPHost const String &  smtpHost  )  [inline]
 

The SMTPHost option takes a string value which should be a the host name of the SMTP server that will send the e-mail message.

void setSubject const String &  subject  )  [inline]
 

The Subject option takes a string value which should be a the subject of the e-mail message.

void setTo const String &  to  )  [inline]
 

The To option takes a string value which should be a comma separated list of e-mail address of the recipients.


The documentation for this class was generated from the following files:
  • smtpappender.h
  • smtpappender.cpp

Copyright © 1999-2004, Apache Software Foundation