Il plugin per il logging degli errori SQL

Stai visualizzando una vecchia versione di questo article. Visualizza la versione più recente.

Talvolta risulta utile registrare in un file di log gli errori restituiti ai client, per poterli analizzare successivamente. Il plugin SQL_ERROR_LOG, aggiunto in MariaDB 5.5, serve proprio a questo. E' implementato come MYSQL_AUDIT_PLUGIN, pertanto una volta installato questo plugin riceve le notifiche degli errori dal server e le registra nel file specificato. Supporta la rotazione dei file d log.

Ecco il comando tipico per abilitare il plugin per il log degli errori SQL:

	install plugin SQL_ERROR_LOG soname 'sql_errlog.so';

Oppure si può aggiungere --plugin-load=sql_errlog.so alla riga di comando del server, o alla sezione [mysqld] del file my.cnf utilizzato.

Per disabilitarlo:

	uninstall plugin SQL_ERROR_LOG;

Il plugin SQL_ERROR_LOG dichiara 5 variabili, che ne influenzano il comportamento:

  • @sql_error_log_filename - string value. The name of the logfile.
    rotation of it will be named like @sql_error_log_filename.001
  • @sql_error_log_rate - integer value, the rate of logging.
    SET @sql_error_log_rate:=300; means that one of 300 errors will be written to the log.
    If the @sql_error_log_rate is 0 - the logging is disabled.
    The default rate is 1 (each error is logged).
  • @sql_error_log_size_limit - integer value, the 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_rotations - integer value, the 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.
  • @sql_error_log_rotate - boolean value.
    This is the 'write-only' variable. Assigning TRUE to this variable forces the log rotation.

Commenti

Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.