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. 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.
Currently, all log modules have an enabled parameter, allowing the module to be temporarily disabled. If enabled="no" is configured, then the module is disabled. If set to any other value, or omitted, then the module is enabled.
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.
Currently, the following standard logger modules are available:
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
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:
Mon 2014 Apr 6 15:58:17 : select 1 from dual time: 0.000001
Sample log: sqlr-connection-oracletest-querylog.2899
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.