Class KLogJDBCHandler

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

public class KLogJDBCHandler extends Handler
Java logging handler to output logging data to any compliant JDBC database. The log data rows are deleted according to the parameter retensiondays during KLogJDBCHandler class instantiation. If the table does not exist during class instantiation, the table will be created with the following SQL statement:
 CREATE TABLE {TableName} (UUID CHAR(36), LOGTIME TIMESTAMP, LEVEL VARCHAR(20), LOCATION VARCHAR(80), TEXT VARCHAR(500))
 
The following properties are supported:
 ch.k43.util.KLogJDBCHandler.jdbc.driver = Java class name
 ch.k43.util.KLogJDBCHandler.jdbc.url = JDBC connection URL, e.g. jdbc:h2:/Users/jsmith/KLogDB
 ch.k43.util.KLogJDBCHandler.jdbc.username = User name
 ch.k43.util.KLogJDBCHandler.jdbc.password = Password
 ch.k43.util.KLogJDBCHandler.tablename = SQL table name (default KLOGDATA)
 ch.k43.util.KLogJDBCHandler.retensiondays = Number of days before log records are deleted (default 30)
 ch.k43.util.KLogJDBCHandler.debug = true/false (Output sent to System.out/System.err, default false)   
 
Since:
2024.06.16
  • Constructor Details

    • KLogJDBCHandler

      public KLogJDBCHandler()
      Class constructor.
  • Method Details

    • close

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

      public void flush()
      Commit JDBC transaction.
      Specified by:
      flush in class Handler
    • publish

      public void publish(LogRecord argRecord)
      Write log record to JDBC database.
      Specified by:
      publish in class Handler
      Parameters:
      argRecord - Log record
    • toString

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