3.27. <Log SQL>

This optional clause creates an SQL logger, which will log all messages with a priority level of Trace or more to an SQL database. The logging is in addition to any logging to the file defined by LogFile. For more information, see Section 3.7.13. LogFile. This clause supports all the common SQL configuration parameters. For more information about the SQL configuration parameters, see Section 3.8. SQL configuration.
The messages are inserted with the following SQL statement:
insert into tablename (TIME_STAMP, PRIORITY, MESSAGE) 
            values (time, priority, 'message')
You must create a table to insert into before you can use this clause. There are example logging tables created in the example SQL files in the goodies/ directory of the Radiator distribution.
The logger becomes active when it is encountered in the configuration file. It will log parse errors from later in the configuration file and subsequent run-time events. Parse errors from earlier in the configuration file will not be logged through this clause.
You can place a <Log xxxxxx> clause inside any clause in the configuration file. This will cause messages originating from within that clauses code to be logged with the logger prior to being logged with any global loggers. This can be handy for debugging or tracing only certain Realms or AuthBy clauses:
      # This will log messages from within the Handler
      <Log SQL>
            #Trace 2
            DBSource dbi:.......
It is good practice to use a different DBSource than for other SQL clauses in your configuration file. This allows SQL errors on DBSource to be logged.

3.27.1. Table

Defines the name of the SQL table to insert into. Defaults to RADLOG. Special formatting characters are permitted.
# Insert into a table called mylog
Table mylog
You could have Log SQL log to a different table every month with something like:
Table RADLOG%Y%m

3.27.2. Trace

Defines the priority level of messages to be traced. For more information, see Section 3.7.3. Trace.
Packet dumps will only appear if the global Trace level is set to 4 or more.

3.27.3. IgnorePacketTrace

Exclude this logger from PacketTrace debugging.

3.27.4. Identifier

This optional parameter acts as a label that can be useful for custom code in hooks. It can also be referred to by <Log xxxxxx> in any other clause.
<AuthBy whatever>
      # With an Identifier, can refer to this logger from 
      # other clauses
      <Log SQL>
            Identifier mylogger
            DBSource xxxxxx
<AuthBy whatever>
      # This AuthBy will log to the Log SQL above
      Log mylogger

3.27.5. LogQuery

This optional parameter allows you to control the SQL query that is used to insert log messages into the database. Special formatting characters are permitted.
The default is:
values (%t, %0, %2)
The variables are:
  • %t is translated as a special character to the current time.
  • %0 is converted to the message priority (in integer in the range 0 to 4 inclusive).
  • %1 is converted to an ASCII string describing the message priority.
  • %2 is converted to the log message, quoted and escaped.
  • %3 is converted to the table name defined by the Table parameter above.
  • %4 is replaced by the SQL quoted User-Name (or ‘NULL’ if there is no current Access-Request).
  • %5 is replaced by the tracing identifier string.
You might want to use either %1 or %2 in your query, but rarely both.

3.27.6. LogQueryParam

This optional parameter specifies a bind variable to be used with LogQuery. Special formatting characters %0 - %5 are not quoted when used with LogQueryParam.For more information, see Section 3.8.1. SQL bind variables.
Many databases do not allow the table name to be defined as a bind variable. If you need %3 and want to use LogQueryParam, use something like this:
LogQuery insert into %3 (TIME_STAMP, PRIORITY_MESSAGE) values
(?, ?, ?)
LogQueryParam %t
LogQueryParam %0
LogQueryParam %2

3.27.7. MaxMessageLength

This optional parameter specifies a maximum message length (in characters) for each message to be logged. If specified, each log message is truncated to the specified number of characters prior to logging. Defaults to 0, which means no truncation.
Truncation is done prior to SQL quoting of escapes. MaxMessageLength is useful for some types of SQL server that complain if given a string longer than the column it is going in to.