org.apache.log.output.net
Class SMTPOutputLogTarget

java.lang.Object
  extended byorg.apache.log.output.AbstractTarget
      extended byorg.apache.log.output.AbstractOutputTarget
          extended byorg.apache.log.output.net.SMTPOutputLogTarget
All Implemented Interfaces:
Closeable, ErrorAware, LogTarget

public class SMTPOutputLogTarget
extends AbstractOutputTarget

Logkit output target that logs data via SMTP.

Since:
1.1.0
Version:
$Id: SMTPOutputLogTarget.java 231246 2005-08-10 14:32:43Z leif $
Author:
Avalon Development Team, Marcus Crafter

Constructor Summary
SMTPOutputLogTarget(javax.mail.Session session, javax.mail.Address[] toAddresses, javax.mail.Address fromAddress, java.lang.String subject, int maxMsgSize, Formatter formatter)
          SMTPOutputLogTarget constructor.
SMTPOutputLogTarget(javax.mail.Session session, javax.mail.Address[] toAddresses, javax.mail.Address fromAddress, java.lang.String subject, int maxMsgSize, int maxDelayTime, Formatter formatter)
          SMTPOutputLogTarget constructor.
 
Method Summary
 void close()
          Closes this log target.
 void setDebug(boolean flag)
          Method to enable/disable debugging on the mail session.
protected  void write(java.lang.String data)
          Method to write data to the log target.
 
Methods inherited from class org.apache.log.output.AbstractOutputTarget
doProcessEvent, getFormatter, open
 
Methods inherited from class org.apache.log.output.AbstractTarget
getErrorHandler, isOpen, processEvent, setErrorHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMTPOutputLogTarget

public SMTPOutputLogTarget(javax.mail.Session session,
                           javax.mail.Address[] toAddresses,
                           javax.mail.Address fromAddress,
                           java.lang.String subject,
                           int maxMsgSize,
                           int maxDelayTime,
                           Formatter formatter)
SMTPOutputLogTarget constructor. It creates a logkit output target capable of logging to SMTP (ie. email, email gateway) targets.

Parameters:
session - mail session to be used
toAddresses - addresses logs should be sent to
fromAddress - address logs say they come from
subject - subject line logs should use
maxMsgSize - maximum size of any log mail, in units of log events. If this is greater than one but maxDelayTime is 0 then log events may stay queued for a long period of time if less than the specified number of messages are logged. Any unset messages will be sent when the target is closed.
maxDelayTime - specifies the longest delay in seconds that a log entry will be queued before being sent. Setting this to a value larger than 0 will cause a background thread to be used to queue up and send messages. Ignored if maxMsgSize is 1 or less.
formatter - log formatter to use

SMTPOutputLogTarget

public SMTPOutputLogTarget(javax.mail.Session session,
                           javax.mail.Address[] toAddresses,
                           javax.mail.Address fromAddress,
                           java.lang.String subject,
                           int maxMsgSize,
                           Formatter formatter)
SMTPOutputLogTarget constructor. It creates a logkit output target capable of logging to SMTP (ie. email, email gateway) targets.

Parameters:
session - mail session to be used
toAddresses - addresses logs should be sent to
fromAddress - address logs say they come from
subject - subject line logs should use
maxMsgSize - maximum size of any log mail, in units of log events. Log events may stay queued for a long period of time if less than the specified number of messages are logged. Any unset messages will be sent when the target is closed.
formatter - log formatter to use
Method Detail

write

protected void write(java.lang.String data)
Method to write data to the log target. Logging data is stored in an internal buffer until the size limit is reached. When this happens the data is sent to the SMTP target, and the buffer is reset for subsequent events.

Overrides:
write in class AbstractOutputTarget
Parameters:
data - logging data to be written to target

close

public void close()
Closes this log target. Sends currently buffered message, if existing.

Specified by:
close in interface Closeable
Overrides:
close in class AbstractOutputTarget

setDebug

public void setDebug(boolean flag)
Method to enable/disable debugging on the mail session.

Parameters:
flag - true to enable debugging, false to disable it


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.