|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.protomatter.syslog.BasicLogger | +--com.protomatter.syslog.DatabaseLog
A logger that writes to a database. The tables it requires are:
CREATE TABLE SYSLOG_LEVEL ( SYSLOG_LEVEL INT PRIMARY KEY, SYSLOG_LEVEL_NAME VARCHAR(8) NOT NULL ) CREATE TABLE SYSLOG_CHANNEL ( CHANNEL INT PRIMARY KEY, CHANNEL_NAME VARCHAR(128) NOT NULL ) CREATE TABLE SYSLOG_LOG ( LOG_TIME DATETIME NOT NULL, SYSLOG_LEVEL INT NOT NULL REFERENCES SYSLOG_LEVEL(SYSLOG_LEVEL), HOST VARCHAR(32) NOT NULL, LOGGER VARCHAR(64) NOT NULL, CHANNEL INT NOT NULL REFERENCES SYSLOG_CHANNEL(CHANNEL), MESSAGE VARCHAR(255) NOT NULL, DETAIL LONG NULL, THREAD_NAME VARCHAR(255) NULL )
NOTE: To use this logger you must specify the "hostname" attribute for the <Syslog> tag in your configuration so that the hostname is correctly recorded.
Column widths are defined as follows:
You may add a prefix to the names of each of the tables and specify that with the "jdbc.tablePrefix" property when initializing this logger. The default prefix is nothing.
You may have to change the type for SYSLOG_LOG.DETAIL
to be something different for your database
(VARCHAR2, LONG VARCHAR or LONG RAW, etc).
It is written using an adapter class which implements
the DatabaseLogStatementAdapter
interface. Currently there are adapters for drivers which
use the setString()
,
setAsciiStream()
, or
setCharacterStream()
methods.
The SYSLOG_LEVEL table needs to contain the following rows:
SYSLOG_LEVEL | SYSLOG_LEVEL_NAME |
1 | DEBUG |
2 | INFO |
4 | WARNING |
8 | ERROR |
16 | FATAL |
The SYSLOG_CHANNEL table is populated automatically. Channel IDs start at 1 and go up from there.
XML configuration class
Fields inherited from class com.protomatter.syslog.BasicLogger |
formatter, policy, realPolicy |
Constructor Summary | |
DatabaseLog()
You will need to call the configure() method if you use this constructor. |
Method Summary | |
void |
flush()
Flush the given logger's output. |
int |
getDetailWidth()
Get the width of the message detail column. |
java.lang.String |
getDriver()
Get the classname of the driver. |
int |
getMessageWidth()
Get the width of the short message column. |
int |
getNumRetries()
Get the number of retries before failure. |
java.util.Properties |
getProperties()
Get the JDBC connection properties. |
DatabaseLogStatementAdapter |
getStatementAdapter()
Get the database statement adapter. |
java.lang.String |
getTablePrefix()
Get the table prefix. |
java.lang.String |
getURL()
Get the JDBC URL. |
void |
initDatabase()
(re)initialize the connection to the database. |
void |
log(SyslogMessage message)
Log an entry to the log. |
void |
setDetailWidth(int width)
Set the width of the message detail column. |
void |
setDriver(java.lang.String driver)
Set the driver to use. |
void |
setMessageWidth(int width)
Set the width of the short message column. |
void |
setNumRetries(int retries)
Set the number of retries before failure. |
void |
setProperties(java.util.Properties props)
Set the JDBC connection properties. |
void |
setStatementAdapter(DatabaseLogStatementAdapter adapter)
Set the database statement adapter. |
void |
setTablePrefix(java.lang.String tablePrefix)
Set the table prefix to use. |
void |
setTextFormatter(SyslogTextFormatter formatter)
Set the log formatter object used by this logger. |
void |
setURL(java.lang.String url)
Set the JDBC URL. |
void |
shutdown()
Close the database connection and cleanup. |
Methods inherited from class com.protomatter.syslog.BasicLogger |
formatLogEntry, getName, getPolicy, getTextFormatter, isSuspended, mightLog, resetDateFormat, resume, setName, setPolicy, shouldLog, suspend |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DatabaseLog()
Method Detail |
public void shutdown()
public void setDriver(java.lang.String driver)
public void setTablePrefix(java.lang.String tablePrefix)
public void setURL(java.lang.String url)
public void setNumRetries(int retries)
public void setProperties(java.util.Properties props)
public void setStatementAdapter(DatabaseLogStatementAdapter adapter)
public DatabaseLogStatementAdapter getStatementAdapter()
public java.lang.String getDriver()
public java.lang.String getTablePrefix()
public java.lang.String getURL()
public int getNumRetries()
public java.util.Properties getProperties()
public void setMessageWidth(int width)
public int getMessageWidth()
public void setDetailWidth(int width)
public int getDetailWidth()
public void initDatabase() throws java.lang.Exception
public final void log(SyslogMessage message)
Syslogger
public void setTextFormatter(SyslogTextFormatter formatter)
setTextFormatter
in class BasicLogger
public void flush()
Syslogger
|
Protomatter Classes v1.1.6 Copyright 1998-2001 Nate Sammons |
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Protomatter Classes v1.1.6 | http://protomatter.sourceforge.net/1.1.6 |