Class SmtpAppender
java.lang.Object
org.apache.logging.log4j.core.AbstractLifeCycle
org.apache.logging.log4j.core.filter.AbstractFilterable
org.apache.logging.log4j.core.appender.AbstractAppender
org.apache.logging.log4j.core.appender.SmtpAppender
- All Implemented Interfaces:
Appender
,Filterable
,LocationAware
,LifeCycle
,LifeCycle2
@Plugin(name="SMTP",
category="Core",
elementType="appender",
printObject=true)
public final class SmtpAppender
extends AbstractAppender
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
-
Field Summary
Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
Fields inherited from interface org.apache.logging.log4j.core.Appender
ELEMENT_TYPE, EMPTY_ARRAY
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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 SmtpAppender
createAppender
(Configuration config, String name, String to, String cc, String bcc, String from, String replyTo, String subject, String smtpProtocol, String smtpHost, String smtpPortStr, String smtpUsername, String smtpPassword, String smtpDebug, String bufferSizeStr, Layout<? extends Serializable> layout, Filter filter, String ignore) Deprecated.boolean
isFiltered
(LogEvent event) Capture all events in CyclicBuffer.static SmtpAppender.Builder
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
error, error, error, getHandler, getLayout, getName, ignoreExceptions, parseInt, requiresLocation, setHandler, toSerializable, toString
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable
addFilter, getFilter, getPropertyArray, hasFilter, removeFilter, start, stop, stop
Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
-
Method Details
-
getManager
-
newBuilder
- Since:
- 2.13.2
-
createAppender
@Deprecated public static SmtpAppender createAppender(@PluginConfiguration Configuration config, @PluginAttribute("name") @Required String name, @PluginAttribute("to") String to, @PluginAttribute("cc") String cc, @PluginAttribute("bcc") String bcc, @PluginAttribute("from") String from, @PluginAttribute("replyTo") String replyTo, @PluginAttribute("subject") String subject, @PluginAttribute("smtpProtocol") String smtpProtocol, @PluginAttribute("smtpHost") String smtpHost, @PluginAttribute(value="smtpPort",defaultString="0") @ValidPort String smtpPortStr, @PluginAttribute("smtpUsername") String smtpUsername, @PluginAttribute(value="smtpPassword",sensitive=true) String smtpPassword, @PluginAttribute("smtpDebug") String smtpDebug, @PluginAttribute("bufferSize") String bufferSizeStr, @PluginElement("Layout") Layout<? extends Serializable> layout, @PluginElement("Filter") Filter filter, @PluginAttribute("ignoreExceptions") String ignore) Deprecated.UsenewBuilder()
to create and configure aSmtpAppender.Builder
instance.Create a SmtpAppender.- See Also:
-
isFiltered
Capture all events in CyclicBuffer.- Specified by:
isFiltered
in interfaceFilterable
- Overrides:
isFiltered
in classAbstractFilterable
- Parameters:
event
- The Log event.- Returns:
- true if the event should be filtered.
-
append
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.
-
newBuilder()
to create and configure aSmtpAppender.Builder
instance.