Apache Log4cxx
Version 1.2.0
|
Send an e-mail when a specific logging event occurs, typically when an ERROR level logging event is sent to the appender. More...
#include <smtpappender.h>
Public Member Functions | |
SMTPAppender () | |
SMTPAppender (log4cxx::helpers::Pool &p) | |
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. | |
~SMTPAppender () | |
void | setOption (const LogString &option, const LogString &value) override |
Set option to value . | |
void | activateOptions (helpers::Pool &p) override |
Activate the options that were previously set with calls to option setters. | |
void | append (const spi::LoggingEventPtr &event, helpers::Pool &p) override |
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. | |
void | close () override |
Release any resources allocated within the appender such as file handles, network connections, etc. | |
LogString | getTo () const |
Returns value of the To option. | |
LogString | getCc () const |
Returns value of the cc option. | |
LogString | getBcc () const |
Returns value of the bcc option. | |
bool | requiresLayout () const override |
The SMTPAppender requires a Layout . | |
void | sendBuffer (log4cxx::helpers::Pool &p) |
Send the contents of the cyclic buffer as an e-mail message. | |
LogString | getEvaluatorClass () |
Returns value of the EvaluatorClass option. | |
LogString | getFrom () const |
Returns value of the From option. | |
LogString | getSubject () const |
Returns value of the Subject option. | |
void | setFrom (const LogString &from) |
The From option takes a string value which should be a e-mail address of the sender. | |
void | setSubject (const LogString &subject) |
The Subject option takes a string value which should be a the subject of the 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. | |
void | setSMTPHost (const LogString &smtpHost) |
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. | |
LogString | getSMTPHost () const |
Returns value of the SMTPHost option. | |
void | setSMTPPort (int port) |
The SMTPPort option takes a string value which should be a the port of the SMTP server that will send the e-mail message. | |
int | getSMTPPort () const |
Returns value of the SMTPHost option. | |
void | setTo (const LogString &to) |
The To option takes a string value which should be a comma separated list of e-mail address of the recipients. | |
void | setCc (const LogString &to) |
The Cc option takes a string value which should be a comma separated list of e-mail address of the cc'd recipients. | |
void | setBcc (const LogString &to) |
The Bcc option takes a string value which should be a comma separated list of e-mail address of the bcc'd recipients. | |
void | setSMTPUsername (const LogString &newVal) |
The SMTPUsername option takes a string value which should be a the user name for the SMTP server. | |
LogString | getSMTPUsername () const |
Returns value of the SMTPUsername option. | |
void | setSMTPPassword (const LogString &newVal) |
The SMTPPassword option takes a string value which should be a the password for the SMTP server. | |
LogString | getSMTPPassword () const |
Returns value of the SMTPPassword option. | |
int | getBufferSize () const |
Returns value of the BufferSize option. | |
log4cxx::spi::TriggeringEventEvaluatorPtr | getEvaluator () const |
Gets the current triggering evaluator. | |
void | setEvaluator (log4cxx::spi::TriggeringEventEvaluatorPtr &trigger) |
Sets the triggering evaluator. | |
void | setEvaluatorClass (const LogString &value) |
The EvaluatorClass option takes a string value representing the name of the class implementing the spi::TriggeringEventEvaluator interface. | |
void | setLocationInfo (bool locationInfo) |
The LocationInfo option is provided for compatibility with log4j and has no effect in log4cxx. | |
bool | getLocationInfo () const |
Returns value of the LocationInfo option. | |
Public Member Functions inherited from log4cxx::AppenderSkeleton | |
AppenderSkeleton () | |
AppenderSkeleton (const LayoutPtr &layout) | |
virtual | ~AppenderSkeleton () |
void | finalize () |
Finalize this appender by calling the derived class' close method. | |
void | activateOptions (helpers::Pool &) override |
Activate the options that were previously set with calls to option setters. | |
void | setOption (const LogString &option, const LogString &value) override |
Set option to value . | |
void | addFilter (const spi::FilterPtr newFilter) override |
Add a filter to end of the filter list. | |
void | clearFilters () override |
Clear the filters chain. | |
const spi::ErrorHandlerPtr | getErrorHandler () const |
Return the currently set spi::ErrorHandler for this Appender. | |
spi::FilterPtr | getFilter () const override |
Returns the head Filter. | |
const spi::FilterPtr | getFirstFilter () const |
Return the first filter in the filter chain for this Appender. | |
LayoutPtr | getLayout () const override |
Returns the layout of this appender. | |
LogString | getName () const override |
Returns the name of this Appender. | |
const LevelPtr | getThreshold () const |
Returns this appenders threshold level. | |
bool | isAsSevereAsThreshold (const LevelPtr &level) const |
Check whether the message level is below the appender's threshold. | |
void | doAppend (const spi::LoggingEventPtr &event, helpers::Pool &pool) override |
This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific AppenderSkeleton::append method. | |
void | setErrorHandler (const spi::ErrorHandlerPtr eh) |
Set the ErrorHandler for this Appender. | |
void | setLayout (const LayoutPtr layout1) override |
Set the layout for this appender. | |
void | setName (const LogString &name1) override |
Set the name of this Appender. | |
void | setThreshold (const LevelPtr &threshold) |
Set the threshold level. | |
Public Member Functions inherited from log4cxx::Appender | |
virtual | ~Appender () |
virtual void | addFilter (const spi::FilterPtr newFilter)=0 |
Add a filter to the end of the filter list. | |
virtual spi::FilterPtr | getFilter () const =0 |
Returns the head Filter. | |
virtual void | clearFilters ()=0 |
Clear the list of filters by removing all the filters in it. | |
virtual void | close ()=0 |
Release any resources allocated within the appender such as file handles, network connections, etc. | |
virtual void | doAppend (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool)=0 |
Log in Appender specific way. | |
virtual LogString | getName () const =0 |
Get the name of this appender. | |
virtual void | setLayout (const LayoutPtr layout)=0 |
Set the Layout for this appender. | |
virtual LayoutPtr | getLayout () const =0 |
Returns this appenders layout. | |
virtual void | setName (const LogString &name)=0 |
Set the name of this appender. | |
virtual bool | requiresLayout () const =0 |
Configurators call this method to determine if the appender requires a layout. | |
Public Member Functions inherited from log4cxx::spi::OptionHandler | |
virtual | ~OptionHandler () |
virtual void | activateOptions (helpers::Pool &p)=0 |
Activate the options that were previously set with calls to option setters. | |
virtual void | setOption (const LogString &option, const LogString &value)=0 |
Set option to value . | |
Public Member Functions inherited from log4cxx::helpers::Object | |
virtual | ~Object () |
virtual const helpers::Class & | getClass () const =0 |
virtual bool | instanceof (const Class &clazz) const =0 |
virtual const void * | cast (const Class &clazz) const =0 |
Additional Inherited Members | |
Protected Member Functions inherited from log4cxx::AppenderSkeleton | |
AppenderSkeleton (LOG4CXX_PRIVATE_PTR(AppenderSkeletonPrivate) priv) | |
virtual void | append (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &p)=0 |
Subclasses of AppenderSkeleton should implement this method to perform actual logging. | |
void | doAppendImpl (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool) |
Send an e-mail when a specific logging event occurs, typically when an ERROR level logging event is sent to the appender.
A value must be provided for the following param elements :
The following param elements are optional:
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. By default 512 logging events are kept in its cyclic buffer.evaluatorClass - The registered spi::TriggeringEventEvaluator sub-class that provides the isTriggeringEvent
implementation. This attribute can also be set using the triggeringPolicy element. By default an email is sent when the level of the logging event is greater or equal to ERROR.
An example configuration is:
log4cxx::net::SMTPAppender::SMTPAppender | ( | ) |
log4cxx::net::SMTPAppender::SMTPAppender | ( | log4cxx::helpers::Pool & | p | ) |
The default constructor will instantiate the appender with a spi::TriggeringEventEvaluator that will trigger on events with level ERROR or higher.
log4cxx::net::SMTPAppender::SMTPAppender | ( | spi::TriggeringEventEvaluatorPtr | evaluator | ) |
Use evaluator
passed as parameter as the spi::TriggeringEventEvaluator for this net::SMTPAppender.
log4cxx::net::SMTPAppender::~SMTPAppender | ( | ) |
|
overridevirtual |
Activate the options that were previously set with calls to option setters.
Will not activate and will log an error message if:
.
Reimplemented from log4cxx::AppenderSkeleton.
|
overridevirtual |
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 log4cxx::AppenderSkeleton.
|
overridevirtual |
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 log4cxx::Appender.
LogString log4cxx::net::SMTPAppender::getBcc | ( | ) | const |
Returns value of the bcc option.
int log4cxx::net::SMTPAppender::getBufferSize | ( | ) | const |
Returns value of the BufferSize option.
LogString log4cxx::net::SMTPAppender::getCc | ( | ) | const |
Returns value of the cc option.
log4cxx::spi::TriggeringEventEvaluatorPtr log4cxx::net::SMTPAppender::getEvaluator | ( | ) | const |
Gets the current triggering evaluator.
LogString log4cxx::net::SMTPAppender::getEvaluatorClass | ( | ) |
Returns value of the EvaluatorClass option.
LogString log4cxx::net::SMTPAppender::getFrom | ( | ) | const |
Returns value of the From option.
bool log4cxx::net::SMTPAppender::getLocationInfo | ( | ) | const |
Returns value of the LocationInfo option.
LogString log4cxx::net::SMTPAppender::getSMTPHost | ( | ) | const |
Returns value of the SMTPHost option.
LogString log4cxx::net::SMTPAppender::getSMTPPassword | ( | ) | const |
Returns value of the SMTPPassword option.
int log4cxx::net::SMTPAppender::getSMTPPort | ( | ) | const |
Returns value of the SMTPHost option.
LogString log4cxx::net::SMTPAppender::getSMTPUsername | ( | ) | const |
Returns value of the SMTPUsername option.
LogString log4cxx::net::SMTPAppender::getSubject | ( | ) | const |
Returns value of the Subject option.
LogString log4cxx::net::SMTPAppender::getTo | ( | ) | const |
Returns value of the To option.
|
overridevirtual |
The SMTPAppender
requires a Layout
.
Implements log4cxx::Appender.
void log4cxx::net::SMTPAppender::sendBuffer | ( | log4cxx::helpers::Pool & | p | ) |
Send the contents of the cyclic buffer as an e-mail message.
void log4cxx::net::SMTPAppender::setBcc | ( | const LogString & | to | ) |
The Bcc option takes a string value which should be a comma separated list of e-mail address of the bcc'd recipients.
void log4cxx::net::SMTPAppender::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 log4cxx::net::SMTPAppender::setCc | ( | const LogString & | to | ) |
The Cc option takes a string value which should be a comma separated list of e-mail address of the cc'd recipients.
void log4cxx::net::SMTPAppender::setEvaluator | ( | log4cxx::spi::TriggeringEventEvaluatorPtr & | trigger | ) |
Sets the triggering evaluator.
trigger | triggering evaluator. |
void log4cxx::net::SMTPAppender::setEvaluatorClass | ( | const LogString & | 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 log4cxx::net::SMTPAppender::setFrom | ( | const LogString & | from | ) |
The From option takes a string value which should be a e-mail address of the sender.
void log4cxx::net::SMTPAppender::setLocationInfo | ( | bool | locationInfo | ) |
The LocationInfo option is provided for compatibility with log4j and has no effect in log4cxx.
|
overridevirtual |
Set option
to value
.
Supported options | Supported values | Default value |
---|---|---|
smtpHost | {any} | - |
smtpPort | {int} | 25 |
smtpUserName | {any} | - |
smtpPassword | {any} | - |
from | (1) | - |
to | (1) | - |
cc | (1) | - |
bcc | (1) | - |
subject | {any} | - |
subject | {any} | - |
buffersize | {int} | 512 |
evaluatorClass | (2) | - |
(2) A registered class deriving from TriggeringEventEvaluator
Reimplemented from log4cxx::AppenderSkeleton.
void log4cxx::net::SMTPAppender::setSMTPHost | ( | const LogString & | smtpHost | ) |
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 log4cxx::net::SMTPAppender::setSMTPPassword | ( | const LogString & | newVal | ) |
The SMTPPassword option takes a string value which should be a the password for the SMTP server.
void log4cxx::net::SMTPAppender::setSMTPPort | ( | int | port | ) |
The SMTPPort option takes a string value which should be a the port of the SMTP server that will send the e-mail message.
void log4cxx::net::SMTPAppender::setSMTPUsername | ( | const LogString & | newVal | ) |
The SMTPUsername option takes a string value which should be a the user name for the SMTP server.
void log4cxx::net::SMTPAppender::setSubject | ( | const LogString & | subject | ) |
The Subject option takes a string value which should be a the subject of the e-mail message.
void log4cxx::net::SMTPAppender::setTo | ( | const LogString & | to | ) |
The To option takes a string value which should be a comma separated list of e-mail address of the recipients.