Logging to JDBC
Grace Software
JavaLog

$Revision: 1.1 $
$Date: 1999/10/11 00:05:14 $

Introduction

JavaLog can write each event to a relational database using a JDBC driver. This is a nice alternative to writing events to a file because it allows the user to query the log at any time via SQL and it preserves the distinct data attributes of the events. The way to start this is by specifying the JDBC url to the handler url property, thusly:
    $ java -Dlog.handler.db.url=jdbc:postgresql://grace/logdb
           -Dlog.handler.db.username=username
           -Dlog.handler.db.password=password
           MyClass

Default Schema

The JavaLog JDBCHandler, by default, writes to the database using the following schema:
CREATE TABLE Log (
    eventtime   datetime,
    number      int,
    type        varchar(32),
    thread      varchar(64),
    class       varchar(64),
    function    varchar(64),
    line        varchar(8),
    message     varchar(256),
    object      varchar(256));
The events are written using an SQL statement similar to the following:
insert into Log values (time, num, type, thread, class, function, 
    line, message, object)
Notice that, by default, the SQL insert statement does not specify the column names, just the data, so the names of the columns in the user's database do not need to match those in the above scheme. However, obviously the data types must match in type.

Custom Schema

The user can modify the entire schema at run time by modifying a few properties.
-Dlog.handler.db.table="DifferentTable"
-Dlog.handler.db.columns="time, message"
-Dlog.handler.db.format="'%t', '%m'";
The above properties would generate the following SQL statement:
insert into DifferentTable (time, message) values (time, message)