MySQL :: MySQL 8.4 Reference Manual :: 29.12.22.2 The error_log Table (original) (raw)

29.12.22.2 The error_log Table

Of the logs the MySQL server maintains, one is the error log to which it writes diagnostic messages (seeSection 7.4.2, “The Error Log”). Typically, the server writes diagnostics to a file on the server host or to a system log service. Depending on error log configuration, the server can also write the most recent error events to the Performance Schema error_log table. Granting the SELECT privilege for theerror_log table thus gives clients and applications access to error log contents using SQL queries, enabling DBAs to provide access to the log without the need to permit direct file system access on the server host.

The error_log table supports focused queries based on its more structured columns. It also includes the full text of error messages to support more free-form analysis.

The table implementation uses a fixed-size, in-memory ring buffer, with old events automatically discarded as necessary to make room for new ones.

Example error_log contents:

mysql> SELECT * FROM performance_schema.error_log\G
*************************** 1. row ***************************
    LOGGED: 2020-08-06 09:25:00.338624
 THREAD_ID: 0
      PRIO: System
ERROR_CODE: MY-010116
 SUBSYSTEM: Server
      DATA: mysqld (mysqld 8.4.5) starting as process 96344
*************************** 2. row ***************************
    LOGGED: 2020-08-06 09:25:00.363521
 THREAD_ID: 1
      PRIO: System
ERROR_CODE: MY-013576
 SUBSYSTEM: InnoDB
      DATA: InnoDB initialization has started.
...
*************************** 65. row ***************************
    LOGGED: 2020-08-06 09:25:02.936146
 THREAD_ID: 0
      PRIO: Warning
ERROR_CODE: MY-010068
 SUBSYSTEM: Server
      DATA: CA certificate /var/mysql/sslinfo/cacert.pem is self signed.
...
*************************** 89. row ***************************
    LOGGED: 2020-08-06 09:25:03.112801
 THREAD_ID: 0
      PRIO: System
ERROR_CODE: MY-013292
 SUBSYSTEM: Server
      DATA: Admin interface ready for connections, address: '127.0.0.1' port: 33062

The error_log table has the following columns. As indicated in the descriptions, all but the DATA column correspond to fields of the underlying error event structure, which is described inSection 7.4.2.3, “Error Event Fields”.

SET @@session.time_zone = @@global.log_timestamps;  

If the log_timestamps value is UTC and your system does not have named time zone support installed (seeSection 7.1.15, “MySQL Server Time Zone Support”), set the time zone like this:

SET @@session.time_zone = '+00:00';  

The error_log table has these indexes:

TRUNCATE TABLE is not permitted for the error_log table.

Implementation and Configuration of the error_log Table

The Performance Schemaerror_log table is populated by error log sink components that write to the table in addition to writing formatted error events to the error log. Performance Schema support by log sinks has two parts:

Currently, the traditional-formatlog_sink_internal and JSON-formatlog_sink_json sinks support writing new events to the error_log table and provide a parser for reading previously written error log files.

The log_error_services system variable controls which log components to enable for error logging. Its value is a pipeline of log filter and log sink components to be executed in left-to-right order when error events occur. Thelog_error_services value pertains to populating theerror_log table as follows:

Any configuration that affects output written to the error log affects error_log table contents. This includes settings such as those for verbosity, message suppression, and message filtering. It also applies to information read at startup from a previous log file. For example, messages not written during a previous server instance configured with low verbosity do not become available if the file is read by a current instance configured with higher verbosity.

The error_log table is a view on a fixed-size, in-memory ring buffer, with old events automatically discarded as necessary to make room for new ones. As shown in the following table, several status variables provide information about ongoingerror_log operation.