|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SK.gnome.dwarf.GenericService SK.gnome.dwarf.thread.ThreadService SK.gnome.dwarf.log.GenericLogger SK.gnome.dwarf.log.JDBCLogger
The SQL database logger.
This logger writes log messages to a database table via the JDBC interface. The table must have the following structure:
column type null description --------------------------------------------------------------- datetime datetime no date and time level char(5) no logging level facility varchar(20) no logging facility message text yes message error varchar(50) yes class name of the Java exception/error errormsg text yes error messageThe following sample SQL command can be used to create the appropriate table:
CREATE TABLE log ( datetime DATETIME NOT NULL, level CHAR(5) NOT NULL, facility varchar(2) NOT NULL, message TEXT, error VARCHAR(50), errormsg TEXT );
Field Summary |
Fields inherited from class SK.gnome.dwarf.log.GenericLogger |
facilities, levels, lock, LOG_FACILITY_ALL |
Fields inherited from class SK.gnome.dwarf.thread.ThreadService |
daemon, thread |
Fields inherited from class SK.gnome.dwarf.GenericService |
initParameters, parent |
Fields inherited from interface SK.gnome.dwarf.Service |
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED |
Constructor Summary | |
JDBCLogger(java.lang.String name)
Creates a new JDBCLogger. |
Method Summary | |
void |
init(Server parent)
Initializes the service. |
void |
setDriver(java.lang.String value)
Sets the JDBC driver class. |
void |
setPassword(java.lang.String value)
Sets the JDBC connection password. |
void |
setTable(java.lang.String value)
Sets the database table name. |
void |
setUrl(java.lang.String value)
Sets the JDBC connection URL. |
void |
setUsername(java.lang.String value)
Sets the JDBC connection username. |
void |
shutdown()
Shuts down the service. |
protected boolean |
wouldLog(java.lang.String facility,
LogLevel level)
Decides whether the logger would log a message with the given loggging level and facility. |
protected void |
write(long time,
java.lang.String facility,
LogLevel level,
java.lang.String message,
java.lang.Throwable error)
Writes the message to the database table. |
Methods inherited from class SK.gnome.dwarf.log.GenericLogger |
enableThread, getLastAccessed, log, log, loop, setFacilities, setLevels, setMarkInterval, setRepeatedInterval, start |
Methods inherited from class SK.gnome.dwarf.thread.ThreadService |
finish, run, setDaemon, stop |
Methods inherited from class SK.gnome.dwarf.GenericService |
getAuthenticator, getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getLogger, getName, getParameters, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public JDBCLogger(java.lang.String name)
Method Detail |
public void setDriver(java.lang.String value)
value
- the driver class namepublic void setUrl(java.lang.String value)
value
- the connection urlpublic void setUsername(java.lang.String value)
value
- the usernamepublic void setPassword(java.lang.String value)
value
- the passwordpublic void setTable(java.lang.String value)
value
- the table namepublic void init(Server parent) throws ServiceException
It initializes also the JDBC connection and prepares the database resources.
init
in interface Service
init
in class GenericService
ServiceException
public void shutdown()
It closes also the JDBC connection and frees the database resources.
shutdown
in interface Service
shutdown
in class GenericLogger
protected boolean wouldLog(java.lang.String facility, LogLevel level)
It first checks whether the database connection has been initialized already and then calls the overriden wouldLog method and returns its result.
wouldLog
in class GenericLogger
facility
- the logging facilitylevel
- the logging level
protected void write(long time, java.lang.String facility, LogLevel level, java.lang.String message, java.lang.Throwable error)
Note: if either the message or the error argument is null, the SQL NULL value will be stored to the corresponding column field.
write
in class GenericLogger
time
- the current time of the logged eventfacility
- the log facilitylevel
- the log levelmessage
- the messageerror
- the error (optional)GenericLogger.log(String, LogLevel, String)
,
GenericLogger.log(String, LogLevel, String, Throwable)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |