Class KLogSMTPHandler

java.lang.Object
java.util.logging.Handler
ch.k43.util.KLogSMTPHandler

public class KLogSMTPHandler extends Handler
Java logging handler to send logging data to an SMTP host. To avoid a high number of emails sent to the server, only log data of type error SEVERE is sent. Additionally the number of emails per minutes is restricted. The following properties are supported:
 ch.k43.util.KLogSMTPHandler.mail.from = Sender email address
 ch.k43.util.KLogSMTPHandler.mail.to = recipient(s)
 ch.k43.util.KLogSMTPHandler.mail.subject = subject (default "KLog Error Report")
 ch.k43.util.KLogSMTPHandler.smtp.hostname = host name (default MX record of first recipient domain)
 ch.k43.util.KLogSMTPHandler.smtp.hostport = host port (default 25)
 ch.k43.util.KLogSMTPHandler.smtp.username = user name for authentication (default none)
 ch.k43.util.KLogSMTPHandler.smtp.password = user password for authentication (default none)
 ch.k43.util.KLogSMTPHandler.smtp.tls = true/false (default true)
 ch.k43.util.KLogSMTPHandler.threshold = nn (maximum number of emails per minute, 1 to 10, default 3)
 ch.k43.util.KLogSMTPHandler.debug = true/false (Output sent to System.out/System.err, default false)   
 
Since:
2024.08.26
  • Constructor Details

    • KLogSMTPHandler

      public KLogSMTPHandler()
      Class constructor.
  • Method Details

    • close

      public void close()
      Close the handler.
      Specified by:
      close in class Handler
    • flush

      public void flush()
      Flush the data.
      Specified by:
      flush in class Handler
    • publish

      public void publish(LogRecord argRecord)
      Send log record a email to SMTP host.
      Specified by:
      publish in class Handler
      Parameters:
      argRecord - Log record
    • toString

      public String toString()
      String representation of object.
      Overrides:
      toString in class Object