org.apache.log4j.net
public class SMTPAppender extends AppenderSkeleton
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.
Since: 1.0
Field Summary | |
---|---|
protected CyclicBuffer | cb |
protected TriggeringEventEvaluator | evaluator |
protected Message | msg |
Constructor Summary | |
---|---|
SMTPAppender()
The default constructor will instantiate the appender with a
{@link TriggeringEventEvaluator} that will trigger on events with
level ERROR or higher. | |
SMTPAppender(TriggeringEventEvaluator evaluator)
Use evaluator passed as parameter as the {@link
TriggeringEventEvaluator} for this SMTPAppender. |
Method Summary | |
---|---|
void | activateOptions()
Activate the specified options, such as the smtp host, the
recipient, from, etc. |
protected void | addressMessage(Message msg)
Address message. |
void | append(LoggingEvent 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. |
protected boolean | checkEntryConditions()
This method determines if there is a sense in attempting to append.
|
void | close() |
protected Session | createSession()
Create mail session. |
String | getBcc()
Get the bcc recipient addresses. |
int | getBufferSize()
Returns value of the BufferSize option. |
String | getCc()
Get the cc recipient addresses. |
String | getEvaluatorClass()
Returns value of the EvaluatorClass option. |
String | getFrom()
Returns value of the From option. |
boolean | getLocationInfo()
Returns value of the LocationInfo option. |
boolean | getSMTPDebug()
Get SMTP debug. |
String | getSMTPHost()
Returns value of the SMTPHost option. |
String | getSMTPPassword()
Get SMTP password. |
String | getSMTPUsername()
Get SMTP user name. |
String | getSubject()
Returns value of the Subject option. |
String | getTo()
Returns value of the To option. |
boolean | requiresLayout()
The SMTPAppender requires a {@link
org.apache.log4j.Layout layout}. |
protected void | sendBuffer()
Send the contents of the cyclic buffer as an e-mail message. |
void | setBcc(String addresses)
Set the bcc recipient addresses. |
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 | setCc(String addresses)
Set the cc recipient addresses. |
void | setEvaluatorClass(String value)
The EvaluatorClass option takes a string value
representing the name of the class implementing the {@link
TriggeringEventEvaluator} interface. |
void | setFrom(String from)
The From option takes a string value which should be a
e-mail address of the sender. |
void | setLocationInfo(boolean locationInfo)
The LocationInfo option takes a boolean value. |
void | setSMTPDebug(boolean debug)
Setting the SmtpDebug option to true will cause the mail session to log its server interaction to stdout.
|
void | setSMTPHost(String 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 | setSMTPPassword(String password)
The SmtpPassword option takes a string value which should be the password required to authenticate against
the mail server. |
void | setSMTPUsername(String username)
The SmtpUsername option takes a string value which should be the username required to authenticate against
the mail server. |
void | setSubject(String subject)
The Subject option takes a string value which should be a
the subject of the e-mail message. |
void | setTo(String to)
The To option takes a string value which should be a
comma separated list of e-mail address of the recipients. |
evaluator
passed as parameter as the {@link
TriggeringEventEvaluator} for this SMTPAppender.Parameters: msg message, may not be null.
Throws: MessagingException thrown if error addressing message.
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.
Returns: mail session, may not be null.
Returns: recipient addresses as comma separated string, may be null.
Returns: recipient addresses as comma separated string, may be null.
Returns: SMTP debug flag.
Returns: SMTP password, may be null.
Returns: SMTP user name, may be null.
SMTPAppender
requires a {@link
org.apache.log4j.Layout layout}.Parameters: addresses recipient addresses as comma separated string, may be null.
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.Parameters: addresses recipient addresses as comma separated string, may be null.
Location information extraction is comparatively very slow and should be avoided unless performance is not a concern.
Parameters: debug debug flag.
Parameters: password password, may be null.
Parameters: username user name, may be null.