SQL Relay - Extension Modules - Logger

Logger Modules

- Introduction
- Available Modules
- Custom Modules

Introduction

Logger modules allow the SQL Relay server programs to log various bits of information as they run. A section of the sqlrelay.conf file indicates which modules to load and what parameters to use when logging.

For example, to use the debug module, which logs detailed information for debugging purposes, you would include a section in the sqlrelay.conf file like:

> <instance ...>
> ...
> <loggers>
> <logger module="debug" listener="yes" connection="yes"/>
> </loggers>
> ...
> </intstance>

The module attribute specifies which module to load. The listener and connection attributes are parameters for the module. Different modules may have different parameters, or may have no parameters. In this case, listener="yes" tells the module to log debug info for the sqlr-listener processes and connection="yes" tells the module to log debug info for the sqlr-connection processes.

Multiple log modules may be loaded by specifying multiple logger tags.

Internally, at startup the SQL Relay server processes create instances of the specified logger modules and initialize them. Then, as they run, the call the logger modules' "run" method, passing in an event type, log level and log message. The modules then react to the different events, log levels and messages in a module-specific manner. The "debug" logger module, for example logs every event type at every log level, while the "slowqueries" logger module only logs queries and ignores all other event types.

Available Modules

Currently, the following standard logger modules are available:

- debug
- slowqueries

Additional standard modules will be available in the future.

debug

The debug module logs a great deal of information to about the internal operation of the SQL Relay server to log files in the "debug directory", usually /usr/local/firstworks/var/sqlrelay/debug. It creates files named sqlr-listener."pid" and sqlr-connection."pid" where "pid" is replaced with the process id of the process that is being logged. As new processes are forked, new files are created with debug information about those processes.

This module takes three parameters: listener, connection and perms. The listener parameter may be set to "no" to disable logging of the sqlr-listener processes. The connection parameter may be set to "no" to disable logging of the sqlr-connection processes. Logging is enabled if either parameter is omitted or set to any other value. The perms parameter may be set to any ls -l style permissions string. The default is "rw-------" which translates to read/write for owner only.

The general log format is:

> `mm/dd/yyyy hh:mm:ss TZ processname [pid] : info`

Sample log for main listener process: sqlr-listener.1869
Sample log for child listener process: sqlr-listener.1886
Sample log for connecton process: sqlr-connection.1871

slowqueries

The slowqueries module logs queries that take longer to run than a specified threshold to log files in the "log directory", usually /usr/local/firstworks/var/sqlrelay/log. It creates files named sqlr-connection-"id"-querylog."pid" for each sqlr-connection process where "id" is replaced with the id of the instance from the sqlrelay.conf file and "pid" is replaced with the process id.

This module takes two parameters: sec and usec. Queries that take longer than sec seconds and usec microseconds will be logged. Both parameters default to 0 and omitting them causes all queries to be logged.

The general format is:

>     query:
>     select 1 from dual
>     time: 0.000000

Sample log: sqlr-connection-oracletest-querylog.2899

Custom Modules

Custom modules that log very specific information in very specific formats are also available in the general SQL Relay distribution but they are not intended for general use.

Ultimately it will be possible to develop custom modules from outside of the SQL Relay source tree but it isn't possible at present.