This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Interacting with the database

SQL operations

Create table:

  • If the given table does not exist, AxoSyslog tries to create it with the given column types.

  • The AxoSyslog application automatically creates the required tables and columns, if the user account used to connect to the database has the required privileges.

  • If AxoSyslog cannot create or alter a table, it tries to do it again when it reaches the next time-reopen().

Alter table:

  • If the table structure is different from given structure in an existing table, AxoSyslog tries to add columns in this table but never will delete or modify an existing column.

  • If AxoSyslog cannot create or alter a table, it tries to do it again when reach the next time-reopen().

  • The AxoSyslog application requires read and write access to the SQL table, otherwise it cannot verify that the destination table exists.

Insert table:

  • Insert new records in a table.

  • Inserting the records into the database is performed by a separate thread.

  • The AxoSyslog application automatically performs the escaping required to insert the messages into the database.

  • If insert returns with error, AxoSyslog tries to insert the message +two times by default, then drops it. Retrying time is the value of time-reopen().

Encoding

The AxoSyslog application uses UTF-8 by default when writes logs into database.

Start/stop and reload

Start:

  • The AxoSyslog application will connect to database automatically after starting regardless existing incoming messages.

Stop:

  • The AxoSyslog application will close the connection to database before shutting down.

Possibility of losing logs:

  • The AxoSyslog application cannot lose logs during shutting down if disk buffer was given and it is not full yet.

  • The AxoSyslog application cannot lose logs during shutting down if disk buffer was not given.

Reload:

  • The AxoSyslog application will close the connection to database if it received SIGHUP signal (reload).

  • It will reconnect to the database when it tries to send a new message to this database again.

Macros:

The value of ${SEQNUM} macro will be overridden by sql driver regardless of local or relayed incoming message.

It will be grown continuously.

1 - MySQL-specific interaction methods

To specify the socket to use, set and export the MYSQL_UNIX_PORT environment variable, for example, MYSQL_UNIX_PORT=/var/lib/mysql/mysql.sock; export MYSQL_UNIX_PORT.

2 - MsSQL-specific interaction methods

In SQL Server 2005 this restriction is lifted - kind of. The total length of all key columns in an index cannot exceed 900 bytes.

If you are using null() in your configuration, be sure that the columns allow NULL to insert. Give the column as the following example: "datetime varchar(16) NULL".

The date format used by the MSSQL database must be explicitly set in the /etc/locales.conf file of the AxoSyslog server. [default] date = "%Y-%m-%d %H:%M:%S".