Log4j 1.2.13 | |
Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.log4j.AppenderSkeleton
org.apache.log4j.net.SMTPAppender
public class SMTPAppender
extends AppenderSkeleton
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.
Field Summary | |
protected CyclicBuffer | |
protected TriggeringEventEvaluator | |
protected Message |
Fields inherited from class org.apache.log4j.AppenderSkeleton | |
closed , errorHandler , headFilter , layout , name , tailFilter , threshold |
Constructor Summary | |
| |
|
Method Summary | |
void |
|
void |
|
protected boolean |
|
void |
|
int |
|
String |
|
String |
|
boolean |
|
String |
|
String |
|
String |
|
boolean |
|
protected void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Methods inherited from class org.apache.log4j.AppenderSkeleton | |
activateOptions , addFilter , append , clearFilters , doAppend , finalize , getErrorHandler , getFilter , getFirstFilter , getLayout , getName , getThreshold , isAsSevereAsThreshold , setErrorHandler , setLayout , setName , setThreshold |
public SMTPAppender()
The default constructor will instantiate the appender with aTriggeringEventEvaluator
that will trigger on events with level ERROR or higher.
public SMTPAppender(TriggeringEventEvaluator evaluator)
Useevaluator
passed as parameter as theTriggeringEventEvaluator
for this SMTPAppender.
public void activateOptions()
Activate the specified options, such as the smtp host, the recipient, from, etc.
- Specified by:
- activateOptions in interface OptionHandler
- Overrides:
- activateOptions in interface AppenderSkeleton
public 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.
- Overrides:
- append in interface AppenderSkeleton
protected boolean checkEntryConditions()
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 valuefalse
is returned.
public void close()
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.
- Since:
- 0.8.4
public int getBufferSize()
Returns value of the BufferSize option.
public String getEvaluatorClass()
Returns value of the EvaluatorClass option.
public String getFrom()
Returns value of the From option.
public boolean getLocationInfo()
Returns value of the LocationInfo option.
public String getSMTPHost()
Returns value of the SMTPHost option.
public String getSubject()
Returns value of the Subject option.
public String getTo()
Returns value of the To option.
public boolean requiresLayout()
TheSMTPAppender
requires alayout
.
- Specified by:
- requiresLayout in interface Appender
protected void sendBuffer()
Send the contents of the cyclic buffer as an e-mail message.
public void setBufferSize(int bufferSize)
The BufferSize option takes a positive integer representing the maximum number of logging events to collect in a cyclic buffer. When theBufferSize
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.
public void setEvaluatorClass(String value)
The EvaluatorClass option takes a string value representing the name of the class implementing theTriggeringEventEvaluator
interface. A corresponding object will be instantiated and assigned as the triggering event evaluator for the SMTPAppender.
public void setFrom(String from)
The From option takes a string value which should be a e-mail address of the sender.
public void setLocationInfo(boolean locationInfo)
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.
public 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.
public void setSubject(String subject)
The Subject option takes a string value which should be a the subject of the e-mail message.
public 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.