|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.logging.Handler smtphandler.SMTPHandler
public class SMTPHandler
Send an e-mail when a specific logging record occurs, typically on
WARNING
or SEVERE
The number of LogRecord
objects delivered in this e-mail depend on
the value of bufferSize option. The
SMTPHandler
keeps only the last
bufferSize
records in its cyclic buffer. This
keeps memory requirements at a reasonable level while still
delivering useful application context.
The code in this class is derived from log4j's SMTPAppender class.
Field Summary | |
---|---|
protected CyclicBuffer |
cb
|
protected TriggeringRecordEvaluator |
evaluator
|
Constructor Summary | |
---|---|
SMTPHandler()
|
Method Summary | |
---|---|
protected boolean |
checkEntryConditions()
This method determines if there is a sense in attempting to append. |
void |
close()
|
void |
flush()
|
protected javax.mail.internet.InternetAddress |
getAddress(java.lang.String addressStr)
|
int |
getBufferSize()
Returns value of the bufferSize option. |
protected java.lang.String |
getEmailContentType()
|
java.lang.String |
getEvaluatorClass()
Returns value of the EvaluatorClass option. |
java.lang.String |
getFrom()
Returns value of the From option. |
java.lang.String |
getSmtpHost()
Returns value of the SmtpHost option. |
java.lang.String |
getSmtpPassword()
|
java.lang.String |
getSmtpUsername()
|
java.lang.String |
getSubject()
Returns value of the Subject option. |
java.lang.String |
getTo()
Returns value of the To option. |
protected javax.mail.internet.InternetAddress[] |
parseAddress(java.lang.String addressStr)
|
void |
publish(java.util.logging.LogRecord record)
Perform SMTPHandler specific appending actions, mainly adding the record to a cyclic buffer and checking if the record triggers an e-mail to be sent. |
protected void |
sendBuffer()
Send the contents of the cyclic buffer as an e-mail message. |
void |
setBufferSize(int bufferSize)
The bufferSize option takes a positive integer representing the maximum number of logging records to collect in a cyclic buffer. |
void |
setEvaluatorClass(java.lang.String value)
The evaluatorClass option takes a string value representing the name of the class implementing the TriggeringRecordEvaluator interface. |
void |
setFrom(java.lang.String from)
The from option takes a string value which should be a e-mail address of the sender. |
void |
setSmtpHost(java.lang.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(java.lang.String value)
|
void |
setSmtpUsername(java.lang.String value)
|
void |
setSubject(java.lang.String subject)
The subject option takes a string value which should be a the subject of the e-mail message. |
void |
setTo(java.lang.String to)
The to option takes a string value which should be a e-mail address of the sender. |
java.lang.String |
toString()
|
Methods inherited from class java.util.logging.Handler |
---|
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected CyclicBuffer cb
protected TriggeringRecordEvaluator evaluator
Constructor Detail |
---|
public SMTPHandler()
Method Detail |
---|
public void publish(java.util.logging.LogRecord record)
publish
in class java.util.logging.Handler
protected boolean checkEntryConditions()
It checks whether there is a "To" address set and also if
there is a set evaluator. If these checks fail, then the boolean
value false
is returned.
public void close()
close
in class java.util.logging.Handler
protected javax.mail.internet.InternetAddress getAddress(java.lang.String addressStr)
protected javax.mail.internet.InternetAddress[] parseAddress(java.lang.String addressStr)
public java.lang.String getTo()
protected void sendBuffer()
protected java.lang.String getEmailContentType()
public java.lang.String getEvaluatorClass()
public java.lang.String getFrom()
public java.lang.String getSubject()
public java.lang.String getSmtpHost()
public void flush()
flush
in class java.util.logging.Handler
public int getBufferSize()
public void setFrom(java.lang.String from)
public void setTo(java.lang.String to)
public void setSubject(java.lang.String subject)
public void setBufferSize(int bufferSize)
bufferSize
is reached,
oldest records are deleted as new records are added to the
buffer. By default the size of the cyclic buffer is 512 records.
public void setSmtpHost(java.lang.String smtpHost)
public void setEvaluatorClass(java.lang.String value)
TriggeringRecordEvaluator
interface. A corresponding object will
be instantiated and assigned as the triggering record evaluator
for the SMTPHandler.
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getSmtpPassword()
public void setSmtpPassword(java.lang.String value)
public java.lang.String getSmtpUsername()
public void setSmtpUsername(java.lang.String value)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |