Logback API
Version 0.9.8

ch.qos.logback.core.net
Class SMTPAppenderBase<E>

java.lang.Object
  extended by ch.qos.logback.core.spi.ContextAwareBase
      extended by ch.qos.logback.core.AppenderBase<E>
          extended by ch.qos.logback.core.net.SMTPAppenderBase<E>
All Implemented Interfaces:
Appender<E>, ContextAware, FilterAttachable, LifeCycle
Direct Known Subclasses:
SMTPAppender, SMTPAppender

public abstract class SMTPAppenderBase<E>
extends AppenderBase<E>

An abstract class that provides basic support for sending events to an email address.

Author:
Ceki Gülcü, Sébastien Pennec

Field Summary
protected  EventEvaluator eventEvaluator
           
protected  Layout<E> layout
           
protected  Message msg
           
protected  Layout<E> subjectLayout
           
 
Fields inherited from class ch.qos.logback.core.AppenderBase
name, started
 
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
 
Constructor Summary
SMTPAppenderBase()
           
 
Method Summary
 void addTo(String to)
          The To option takes a string value which should be an e-mail address of one of the recipients.
protected  void append(E eventObject)
          Perform SMTPAppender specific appending actions, delegating some of them to a subclass and checking if the event triggers an e-mail to be sent.
 boolean checkEntryConditions()
          This method determines if there is a sense in attempting to append.
protected abstract  void fillBuffer(StringBuffer sbuf)
           
 String getFrom()
          Returns value of the From option.
 Layout<E> getLayout()
          Returns this appenders layout.
 Message getMessage()
           
 String getSMTPHost()
          Returns value of the SMTPHost option.
 String getSubject()
          Returns value of the Subject option.
 List<String> getTo()
          Returns value of the To option.
protected abstract  Layout<E> makeSubjectLayout(String subjectStr)
          return a layout for the subjet string as appropriate for the module.
protected  void sendBuffer(E lastEventObject)
          Send the contents of the cyclic buffer as an e-mail message.
 void setEvaluator(EventEvaluator eventEvaluator)
          The EventEvaluator option takes a string value representing the name of the class implementing the EventEvaluators interface.
 void setFrom(String from)
          The From option takes a string value which should be a e-mail address of the sender.
 void setLayout(Layout<E> layout)
          Set the Layout for this appender.
 void setMessage(Message msg)
           
 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 setSubject(String subject)
          The Subject option takes a string value which should be a the subject of the e-mail message.
 void start()
          Start the appender
 void stop()
           
protected abstract  void subAppend(E eventObject)
           
 
Methods inherited from class ch.qos.logback.core.AppenderBase
addFilter, clearAllFilters, doAppend, getFilterChainDecision, getFirstFilter, getName, isStarted, setName, toString
 
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getStatusManager, setContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
 

Field Detail

layout

protected Layout<E> layout

subjectLayout

protected Layout<E> subjectLayout

msg

protected Message msg

eventEvaluator

protected EventEvaluator eventEvaluator
Constructor Detail

SMTPAppenderBase

public SMTPAppenderBase()
Method Detail

makeSubjectLayout

protected abstract Layout<E> makeSubjectLayout(String subjectStr)
return a layout for the subjet string as appropriate for the module. If the subjectStr parameter is null, then a default value for subjectStr should be used.

Parameters:
subjectStr -
Returns:
a layout as appropriate for the module

start

public void start()
Start the appender

Specified by:
start in interface LifeCycle
Overrides:
start in class AppenderBase<E>

append

protected void append(E eventObject)
Perform SMTPAppender specific appending actions, delegating some of them to a subclass and checking if the event triggers an e-mail to be sent.

Specified by:
append in class AppenderBase<E>

subAppend

protected abstract void subAppend(E eventObject)

checkEntryConditions

public 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 value false is returned.


stop

public void stop()
Specified by:
stop in interface LifeCycle
Overrides:
stop in class AppenderBase<E>

getTo

public List<String> getTo()
Returns value of the To option.


sendBuffer

protected void sendBuffer(E lastEventObject)
Send the contents of the cyclic buffer as an e-mail message.


fillBuffer

protected abstract void fillBuffer(StringBuffer sbuf)

getFrom

public String getFrom()
Returns value of the From option.


getSubject

public String getSubject()
Returns value of the Subject option.


setFrom

public void setFrom(String from)
The From option takes a string value which should be a e-mail address of the sender.


setSubject

public void setSubject(String subject)
The Subject option takes a string value which should be a the subject of the e-mail message.


setSMTPHost

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.


getSMTPHost

public String getSMTPHost()
Returns value of the SMTPHost option.


addTo

public void addTo(String to)
The To option takes a string value which should be an e-mail address of one of the recipients.


getMessage

public Message getMessage()

setMessage

public void setMessage(Message msg)

setEvaluator

public void setEvaluator(EventEvaluator eventEvaluator)
The EventEvaluator option takes a string value representing the name of the class implementing the EventEvaluators interface. A corresponding object will be instantiated and assigned as the event evaluator for the SMTPAppender.


getLayout

public Layout<E> getLayout()
Description copied from interface: Appender
Returns this appenders layout.

Specified by:
getLayout in interface Appender<E>
Overrides:
getLayout in class AppenderBase<E>

setLayout

public void setLayout(Layout<E> layout)
Description copied from interface: Appender
Set the Layout for this appender.

Specified by:
setLayout in interface Appender<E>
Overrides:
setLayout in class AppenderBase<E>

Logback API
Version 0.9.8

Copyright © 2005-2008 QOS.ch. All Rights Reserved.