|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.log4j.AppenderSkeleton
it.openutils.log4j.AlternateSMTPAppender
public class AlternateSMTPAppender
An alternative of org.apache.log4j.net.SMTPAppender
with few differences:
<appender name="mail" class="it.openutils.log4j.AlternateSMTPAppender"> <param name="Threshold" value="ERROR" /> <param name="To" value="logs@example.com" /> <param name="From" value="info@example.com" /> <param name="SMTPHost" value="localhost" /> <param name="Timeout" value="180" /> <param name="Subject" value="[EXAMPLE] %m" /> <layout class="it.openutils.log4j.FilteredPatternLayout"> <param name="ConversionPattern" value="%-5p %c %d{dd.MM.yyyy HH:mm:ss} -- %m%n" /> <param name="Header" value=" ===================================%n Myapp (production environment)%n Date: %d{dd.MM.yyyy HH:mm:ss}%n Url: %X{url}%n Number of occurrences: %o%n ===================================%n " /> </layout> </appender>
Field Summary | |
---|---|
protected org.apache.log4j.spi.TriggeringEventEvaluator |
evaluator
|
protected java.util.Map<it.openutils.log4j.LoggingEventAggregator,it.openutils.log4j.LoggingEventAggregator> |
events
|
protected javax.mail.Message |
msg
|
Fields inherited from class org.apache.log4j.AppenderSkeleton |
---|
closed, errorHandler, headFilter, layout, name, tailFilter, threshold |
Constructor Summary | |
---|---|
AlternateSMTPAppender()
The default constructor will instantiate the appender with a TriggeringEventEvaluator that will trigger
on events with level ERROR or higher. |
|
AlternateSMTPAppender(org.apache.log4j.spi.TriggeringEventEvaluator evaluator)
Use evaluator passed as parameter as the TriggeringEventEvaluator for this SMTPAppender. |
Method Summary | |
---|---|
void |
activateOptions()
Activate the specified options, such as the smtp host, the recipient, from, etc. |
void |
append(org.apache.log4j.spi.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()
|
int |
getBufferSize()
Returns value of the BufferSize option. |
java.lang.String |
getEvaluatorClass()
Returns value of the EvaluatorClass option. |
java.lang.String |
getFrom()
Returns value of the From option. |
boolean |
getLocationInfo()
Returns value of the LocationInfo option. |
java.lang.String |
getSMTPHost()
Returns value of the SMTPHost option. |
java.lang.String |
getSubject()
Returns value of the Subject option. |
int |
getTimeout()
Returns the timeout. |
java.lang.String |
getTo()
Returns value of the To option. |
boolean |
requiresLayout()
The SMTPAppender requires a layout . |
protected void |
sendBuffer(java.util.Collection<it.openutils.log4j.LoggingEventAggregator> eventsCollection)
Send the contents of the cyclic buffer as an e-mail message. |
void |
setBufferSize(int bufferSize)
Deprecated. |
void |
setEvaluator(org.apache.log4j.spi.TriggeringEventEvaluator value)
|
void |
setEvaluatorClass(java.lang.String value)
The EvaluatorClass option takes a string value representing the name of the class implementing the TriggeringEventEvaluator 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 |
setLocationInfo(boolean locationInfo)
The LocationInfo option takes a boolean value. |
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 |
setSubject(java.lang.String subjectPattern)
The Subject option takes a string value which should be a the subject of the e-mail message. |
void |
setTimeout(int timeout)
Sets the timeout. |
void |
setTo(java.lang.String to)
The To option takes a string value which should be a comma separated list of e-mail address of the recipients. |
Methods inherited from class org.apache.log4j.AppenderSkeleton |
---|
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Map<it.openutils.log4j.LoggingEventAggregator,it.openutils.log4j.LoggingEventAggregator> events
protected javax.mail.Message msg
protected org.apache.log4j.spi.TriggeringEventEvaluator evaluator
Constructor Detail |
---|
public AlternateSMTPAppender()
TriggeringEventEvaluator
that will trigger
on events with level ERROR or higher.
public AlternateSMTPAppender(org.apache.log4j.spi.TriggeringEventEvaluator evaluator)
evaluator
passed as parameter as the TriggeringEventEvaluator
for this SMTPAppender.
Method Detail |
---|
public void activateOptions()
activateOptions
in interface org.apache.log4j.spi.OptionHandler
activateOptions
in class org.apache.log4j.AppenderSkeleton
public void append(org.apache.log4j.spi.LoggingEvent event)
append
in class org.apache.log4j.AppenderSkeleton
protected boolean checkEntryConditions()
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.
public void close()
public java.lang.String getTo()
public boolean requiresLayout()
SMTPAppender
requires a layout
.
protected void sendBuffer(java.util.Collection<it.openutils.log4j.LoggingEventAggregator> eventsCollection)
public java.lang.String getEvaluatorClass()
public java.lang.String getFrom()
public java.lang.String getSubject()
public void setFrom(java.lang.String from)
public void setSubject(java.lang.String subjectPattern)
@Deprecated public void setBufferSize(int bufferSize)
public void setSMTPHost(java.lang.String smtpHost)
public java.lang.String getSMTPHost()
public void setTo(java.lang.String to)
public int getBufferSize()
public void setEvaluatorClass(java.lang.String value)
TriggeringEventEvaluator
interface. A corresponding object will be instantiated and assigned as the
triggering event evaluator for the SMTPAppender.
public void setEvaluator(org.apache.log4j.spi.TriggeringEventEvaluator value)
value
- public void setLocationInfo(boolean locationInfo)
Location information extraction is comparatively very slow and should be avoided unless performance is not a concern.
public boolean getLocationInfo()
public int getTimeout()
public void setTimeout(int timeout)
timeout
- the timeout to set
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |