java.lang.Object | ||
↳ | org.apache.log4j.AppenderSkeleton | |
↳ | org.apache.log4j.net.SMTPAppender |
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.
By default, an email message will be sent when an ERROR or higher
severity message is appended. The triggering criteria can be
modified by setting the evaluatorClass property with the name
of a class implementing TriggeringEventEvaluator, setting the evaluator
property with an instance of TriggeringEventEvaluator or
nesting a triggeringPolicy element where the specified
class implements TriggeringEventEvaluator.
This class has implemented UnrecognizedElementHandler since 1.2.15.
Since 1.2.16, SMTP over SSL is supported by setting SMTPProtocol to "smpts".
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
cb | |||||||||||
evaluator | |||||||||||
msg |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.log4j.AppenderSkeleton
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
The default constructor will instantiate the appender with a
TriggeringEventEvaluator that will trigger on events with
level ERROR or higher. | |||||||||||
Use
evaluator passed as parameter as the TriggeringEventEvaluator for this SMTPAppender. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Activate the specified options, such as the smtp host, the
recipient, from, etc.
| |||||||||||
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.
| |||||||||||
Get the bcc recipient addresses.
| |||||||||||
Returns value of the BufferSize option.
| |||||||||||
Get the cc recipient addresses.
| |||||||||||
Get triggering evaluator.
| |||||||||||
Returns value of the EvaluatorClass option.
| |||||||||||
Returns value of the From option.
| |||||||||||
Returns value of the LocationInfo option.
| |||||||||||
Get the reply addresses.
| |||||||||||
Get SMTP debug.
| |||||||||||
Returns value of the SMTPHost option.
| |||||||||||
Get SMTP password.
| |||||||||||
Get port.
| |||||||||||
Get transport protocol.
| |||||||||||
Get SMTP user name.
| |||||||||||
Get sendOnClose.
| |||||||||||
Returns value of the Subject option.
| |||||||||||
Returns value of the To option.
| |||||||||||
Called to inform a configured object when
an unrecognized child element is encountered.
| |||||||||||
The
SMTPAppender requires a layout . | |||||||||||
Set the bcc recipient addresses.
| |||||||||||
The BufferSize option takes a positive integer
representing the maximum number of logging events to collect in a
cyclic buffer.
| |||||||||||
Set the cc recipient addresses.
| |||||||||||
Sets triggering evaluator.
| |||||||||||
The EvaluatorClass option takes a string value
representing the name of the class implementing the
TriggeringEventEvaluator interface. | |||||||||||
The From option takes a string value which should be a
e-mail address of the sender.
| |||||||||||
The LocationInfo option takes a boolean value.
| |||||||||||
Set the e-mail addresses to which replies should be directed.
| |||||||||||
Setting the SmtpDebug option to true will cause the mail session to log its server interaction to stdout.
| |||||||||||
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.
| |||||||||||
The SmtpPassword option takes a string value which should be the password required to authenticate against
the mail server.
| |||||||||||
Set port.
| |||||||||||
Set transport protocol.
| |||||||||||
The SmtpUsername option takes a string value which should be the username required to authenticate against
the mail server.
| |||||||||||
Set sendOnClose.
| |||||||||||
The Subject option takes a string value which should be a
the subject of the e-mail message.
| |||||||||||
The To option takes a string value which should be a
comma separated list of e-mail address of the recipients.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Address message.
| |||||||||||
This method determines if there is a sense in attempting to append.
| |||||||||||
Create mail session.
| |||||||||||
Layout body of email message.
| |||||||||||
Send the contents of the cyclic buffer as an e-mail message.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.log4j.AppenderSkeleton
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.apache.log4j.Appender
| |||||||||||
From interface
org.apache.log4j.spi.OptionHandler
| |||||||||||
From interface
org.apache.log4j.xml.UnrecognizedElementHandler
|
The default constructor will instantiate the appender with a
TriggeringEventEvaluator
that will trigger on events with
level ERROR or higher.
Use evaluator
passed as parameter as the TriggeringEventEvaluator
for this SMTPAppender.
Activate the specified options, such as the smtp host, the recipient, from, etc.
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.
Get the bcc recipient addresses.
Returns value of the BufferSize option.
Get the cc recipient addresses.
Get triggering evaluator.
Returns value of the EvaluatorClass option.
Returns value of the From option.
Returns value of the LocationInfo option.
Get the reply addresses.
Get SMTP debug.
Returns value of the SMTPHost option.
Get SMTP password.
Get port.
Get transport protocol. Typically null or "smtps".
Get SMTP user name.
Get sendOnClose.
Returns value of the Subject option.
Returns value of the To option.
Called to inform a configured object when an unrecognized child element is encountered.
element | element, may not be null. |
---|---|
props | properties in force, may be null. |
Exception |
---|
Set the bcc recipient addresses.
addresses | recipient addresses as comma separated string, may be null. |
---|
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.
Set the cc recipient addresses.
addresses | recipient addresses as comma separated string, may be null. |
---|
Sets triggering evaluator.
trigger | triggering event evaluator. |
---|
The EvaluatorClass option takes a string value
representing the name of the class implementing the TriggeringEventEvaluator
interface. A corresponding object will
be instantiated and assigned as the triggering event evaluator
for the SMTPAppender.
The From option takes a string value which should be a e-mail address of the sender.
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.
Set the e-mail addresses to which replies should be directed.
addresses | reply addresses as comma separated string, may be null. |
---|
Setting the SmtpDebug option to true will cause the mail session to log its server interaction to stdout. This can be useful when debuging the appender but should not be used during production because username and password information is included in the output.
debug | debug flag. |
---|
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.
The SmtpPassword option takes a string value which should be the password required to authenticate against the mail server.
password | password, may be null. |
---|
Set port.
val | port, negative values indicate use of default ports for protocol. |
---|
Set transport protocol. Typically null or "smtps".
val | transport protocol, may be null. |
---|
The SmtpUsername option takes a string value which should be the username required to authenticate against the mail server.
username | user name, may be null. |
---|
Set sendOnClose.
val | if true all buffered logging events will be sent when appender is closed. |
---|
The Subject option takes a string value which should be a the subject of the e-mail message.
The To option takes a string value which should be a comma separated list of e-mail address of the recipients.
Address message.
msg | message, may not be null. |
---|
MessagingException | thrown if error addressing message. |
---|
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.
Create mail session.
Layout body of email message.
Send the contents of the cyclic buffer as an e-mail message.