MariaDB starting with 5.5.22

This plugin was introduced in MariaDB 5.5.22

The SQL_ERROR_LOG plugin collects errors sent to clients in a log file so that they can later be analyzed.

It is implemented as a MYSQL_AUDIT_PLUGIN, so after it is installed the plugin receives error notifications from the server and stores them to the specified file. The log file can be rotated.

The typical command to enable the SQL errlog plugin:

install plugin SQL_ERROR_LOG soname 'sql_errlog';

or by adding to the server's command line or to the [mysqld] section in your my.cnf file.

To disable it:

uninstall plugin SQL_ERROR_LOG;

The SQL_ERROR_LOG plugin declares 5 variables that control its behavior:

sql_error_log_filenamestringThe name of the logfile. Rotation of it will be named like sql_error_log_filename.001
sql_error_log_rateintegerThe rate of logging. SET sql_error_log_rate=300; means that one of 300 errors will be written to the log.
If sql_error_log_rate is 0 the logging is disabled.
The default rate is 1 (every error is logged).
sql_error_log_size_limitintegerThe limitation for the size of the log file. After reaching the specified limit, the log file is rotated.
1M limit set by default.
sql_error_log_rotationsintegerThe number of rotations. When rotated, the current log file is stored and the new empty one created.
The sql_error_log_rotations logs are stored, older are removed.
The default number of rotations is 9.
sql_error_log_rotatebooleanThis is the 'write-only' variable. Assigning TRUE to this variable forces the log rotation.

Comments are logged too, which makes the statements easier to search. But this is only possible if the client does not strip the comments away. For example, if the queries are entered in the mysql command-line client, it must be started with the --comments option.


install plugin SQL_ERROR_LOG soname 'sql_errlog';
Query OK, 0 rows affected (0.00 sec)

use test;
Database changed

Query OK, 0 rows affected (0.00 sec)

ERROR 1286 (42000): Unknown storage engine 'WHOOPSIE'
\! cat data/sql_errors.log
2013-03-19  9:38:40 msandbox[msandbox] @ localhost [] ERROR 1286: Unknown storage engine 'WHOOPSIE' : CREATE TABLE foo2 (id int) ENGINE=WHOOPSIE


Comments loading...