org.apache.logging.log4j.core.appender
Class SMTPAppender<T extends Serializable>

java.lang.Object
  extended by org.apache.logging.log4j.core.filter.AbstractFilterable
      extended by org.apache.logging.log4j.core.appender.AbstractAppender<T>
          extended by org.apache.logging.log4j.core.appender.SMTPAppender<T>
Type Parameters:
T - The Layout's Serializable type.
All Implemented Interfaces:
Appender<T>, Filterable, LifeCycle

public final class SMTPAppender<T extends Serializable>
extends AbstractAppender<T>

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 formatted as HTML. This can be modified by setting a layout for the appender. By default, an email message will be sent when an ERROR or higher severity message is appended. This can be modified by setting a filter for the appender.


Field Summary
protected  SMTPManager manager
          The SMTP Manager
 
Fields inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
LOGGER
 
Method Summary
 void append(LogEvent event)
          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.
static
<S extends Serializable>
SMTPAppender<S>
createAppender(String name, String to, String cc, String bcc, String from, String replyTo, String subject, String smtpProtocol, String smtpHost, String smtpPortNum, String smtpUsername, String smtpPassword, String smtpDebug, String bufferSizeNum, Layout<S> layout, Filter filter, String suppressExceptions)
          Create a SMTPAppender.
 boolean isFiltered(LogEvent event)
          Capture all events in CyclicBuffer.
 
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
error, error, error, getHandler, getLayout, getName, isExceptionSuppressed, isStarted, parseInt, setHandler, start, stop, toString
 
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable
addFilter, getFilter, hasFilter, removeFilter, startFilter, stopFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

manager

protected final SMTPManager manager
The SMTP Manager

Method Detail

createAppender

public static <S extends Serializable> SMTPAppender<S> createAppender(String name,
                                                                      String to,
                                                                      String cc,
                                                                      String bcc,
                                                                      String from,
                                                                      String replyTo,
                                                                      String subject,
                                                                      String smtpProtocol,
                                                                      String smtpHost,
                                                                      String smtpPortNum,
                                                                      String smtpUsername,
                                                                      String smtpPassword,
                                                                      String smtpDebug,
                                                                      String bufferSizeNum,
                                                                      Layout<S> layout,
                                                                      Filter filter,
                                                                      String suppressExceptions)
Create a SMTPAppender.

Type Parameters:
S - The Layout's Serializable type.
Parameters:
name - The name of the Appender.
to - The comma-separated list of recipient email addresses.
cc - The comma-separated list of CC email addresses.
bcc - The comma-separated list of BCC email addresses.
from - The email address of the sender.
replyTo - The comma-separated list of reply-to email addresses.
subject - The subject of the email message.
smtpProtocol - The SMTP transport protocol (such as "smtps", defaults to "smtp").
smtpHost - The SMTP hostname to send to.
smtpPortNum - The SMTP port to send to.
smtpUsername - The username required to authenticate against the SMTP server.
smtpPassword - The password required to authenticate against the SMTP server.
smtpDebug - Enable mail session debuging on STDOUT.
bufferSizeNum - How many log events should be buffered for inclusion in the message?
layout - The layout to use (defaults to HTMLLayout).
filter - The Filter or null (defaults to ThresholdFilter, level of ERROR).
suppressExceptions - "true" if exceptions should be hidden from the application, "false" otherwise (defaults to "true").
Returns:
The SMTPAppender.

isFiltered

public boolean isFiltered(LogEvent event)
Capture all events in CyclicBuffer.

Specified by:
isFiltered in interface Filterable
Overrides:
isFiltered in class AbstractFilterable
Parameters:
event - The Log event.
Returns:
true if the event should be filtered.

append

public void append(LogEvent event)
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.

Parameters:
event - The Log event.


Copyright © 1999-2013 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.