The sql() driver sends messages into an SQL database.
Currently the Microsoft SQL (MSSQL), MySQL, Oracle, PostgreSQL, and SQLite databases
are supported.
![]() |
Note |
|---|---|
In order to use the |
The sql() driver has the following required parameters:
Table 3.4. Required parameters of the sql() driver
For the list of available optional parameters, see Section 8.2.5, “sql()”.
Declaration:
sql(database_type host_parameters database_parameters [options]);
![]() |
Warning |
|---|---|
|
The syslog-ng application requires read and write access to the SQL table, otherwise it cannot verify that the destination table exists. Currently the syslog-ng application has default schemas for the different databases and uses these defaults if the database schema (e.g., columns and column types) is not defined in the configuration file. However, these schemas will be deprecated and specifying the exact database schema will be required in later versions of syslog-ng. |
![]() |
Note |
|---|---|
|
In addition to the standard syslog-ng packages, the
The |
The table and value parameters can
include macros to create tables and columns dynamically (see Section 8.5, “Macros” for details).
![]() |
Warning |
|---|---|
When using macros in table names, note that some databases limit the maximum allowed length of table names. Consult the documentation of the database for details. |
Inserting the records into the database is performed by a separate thread. The syslog-ng application automatically performs the escaping required to insert the messages into the database.
The Oracle sql destination has some special aspects that are important to note.
The hostname of the database server is set in the
tnsnames.ora file, not in the
host parameter of the
sql() destination.
Make sure to set the Oracle-related environment variables properly, so
syslog-ng and the Oracle client will find the file. The following
variables must be set: ORACLE_BASE,
ORACLE_HOME, and
ORACLE_SID. See the documentation of the Oracle
Instant Client for details.
As certain database versions limit the maximum length of table names, macros in the table names should be used with care.
In the current version of syslog-ng PE, the types of database columns
must be explicitly set for the Oracle destination. The column used to
store the text part of the syslog messages should be able to store
messages as long as the longest message permitted by syslog-ng,
therefore it is usually recommended to use the
varchar2 or clob column
type. (The maximum length of the messages can be set using the
log_msg_size() option.) See the following
example for details.
The mssql database driver can access Microsoft SQL
(MSSQL) destinations. This driver has some special aspects that are important to
note.
The date format used by the MSSQL database must be explicitly set in
the /etc/locales.conf file of the syslog-ng server.
See the following example for details.
As certain database versions limit the maximum length of table names, macros in the table names should be used with care.
In the current version of syslog-ng PE, the types of database columns
must be explicitly set for the MSSQL destination. The column used to
store the text part of the syslog messages should be able to store
messages as long as the longest message permitted by syslog-ng. The
varchar column type can store maximum 4096
bytes-long messages. The maximum length of the messages can be set using
the log_msg_size() option. See the following
example for details.
Remote access for SQL users must be explicitly enabled on the Microsoft Windows host running the Microsoft SQL Server. See Section 4.6, “Configuring Microsoft SQL Server to accept logs from syslog-ng” for details.
© 2007-2010 BalaBit IT Security
Please send your comments or documentation bugs to: documentation@balabit.com