7.4.2.5 Priority-Based Error Log Filtering (log_filter_internal) (original) (raw)

7.4.2.5 Priority-Based Error Log Filtering (log_filter_internal)

The log_filter_internal log filter component implements a simple form of log filtering based on error event priority and error code. To affect howlog_filter_internal permits or suppresses error, warning, and information events intended for the error log, set thelog_error_verbosity andlog_error_suppression_list system variables.

log_filter_internal is built in and enabled by default. If this filter is disabled,log_error_verbosity andlog_error_suppression_list have no effect, so filtering must be performed using another filter service instead where desired (for example, with individual filter rules when using log_filter_dragnet). For information about filter configuration, seeSection 7.4.2.1, “Error Log Configuration”.

Verbosity Filtering

Events intended for the error log have a priority ofERROR, WARNING, orINFORMATION. Thelog_error_verbosity system variable controls verbosity based on which priorities to permit for messages written to the log, as shown in the following table.

log_error_verbosity Value Permitted Message Priorities
1 ERROR
2 ERROR, WARNING
3 ERROR, WARNING,INFORMATION

If log_error_verbosity is 2 or greater, the server logs messages about statements that are unsafe for statement-based logging. If the value is 3, the server logs aborted connections and access-denied errors for new connection attempts. SeeSection B.3.2.9, “Communication Errors and Aborted Connections”.

If you use replication, alog_error_verbosity value of 2 or greater is recommended, to obtain more information about what is happening, such as messages about network failures and reconnections.

If log_error_verbosity is 2 or greater on a replica, the replica prints messages to the error log to provide information about its status, such as the binary log and relay log coordinates where it starts its job, when it is switching to another relay log, when it reconnects after a disconnect, and so forth.

There is also a message priority of SYSTEM that is not subject to verbosity filtering. System messages about non-error situations are printed to the error log regardless of thelog_error_verbosity value. These messages include startup and shutdown messages, and some significant changes to settings.

In the MySQL error log, system messages are labeled as“System”. Other log sinks might or might not follow the same convention, and in the resulting logs, system messages might be assigned the label used for the information priority level, such as “Note” or“Information”. If you apply any additional filtering or redirection for logging based on the labeling of messages, system messages do not override your filter, but are handled by it in the same way as other messages.

Suppression-List Filtering

Thelog_error_suppression_list system variable applies to events intended for the error log and specifies which events to suppress when they occur with a priority of WARNING orINFORMATION. For example, if a particular type of warning is considered undesirable “noise” in the error log because it occurs frequently but is not of interest, it can be suppressed.log_error_suppression_list does not suppress messages with a priority ofERROR or SYSTEM.

Thelog_error_suppression_list value may be the empty string for no suppression, or a list of one or more comma-separated values indicating the error codes to suppress. Error codes may be specified in symbolic or numeric form. A numeric code may be specified with or without the MY- prefix. Leading zeros in the numeric part are not significant. Examples of permitted code formats:

ER_SERVER_SHUTDOWN_COMPLETE
MY-000031
000031
MY-31
31

For readability and portability, symbolic values are preferable to numeric values.

Although codes to be suppressed can be expressed in symbolic or numeric form, the numeric value of each code must be in a permitted range:

In addition, each error code specified must actually be used by MySQL. Attempts to specify a code not within a permitted range or within a permitted range but not used by MySQL produce an error and thelog_error_suppression_list value remains unchanged.

For information about error code ranges and the error symbols and numbers defined within each range, seeSection B.1, “Error Message Sources and Elements”, andMySQL 8.4 Error Message Reference.

The server can generate messages for a given error code at differing priorities, so suppression of a message associated with an error code listed inlog_error_suppression_list depends on its priority. Suppose that the variable has a value of 'ER_PARSER_TRACE,MY-010001,10002'. Thenlog_error_suppression_list has these effects on messages for those codes:

Verbosity and Suppression-List Interaction

The effect oflog_error_verbosity combines with that oflog_error_suppression_list. Consider a server started with these settings:

[mysqld]
log_error_verbosity=2     # error and warning messages only
log_error_suppression_list='ER_PARSER_TRACE,MY-010001,10002'

In this case,log_error_verbosity permits messages with ERROR orWARNING priority and discards messages withINFORMATION priority. Of the nondiscarded messages,log_error_suppression_list discards messages with WARNING priority and any of the named error codes.

Note

The log_error_verbosity value of 2 shown in the example is also its default value, so the effect of this variable onINFORMATION messages is as just described by default, without an explicit setting. You must setlog_error_verbosity to 3 if you wantlog_error_suppression_list to affect messages with INFORMATION priority.

Consider a server started with this setting:

[mysqld]
log_error_verbosity=1     # error messages only

In this case,log_error_verbosity permits messages with ERROR priority and discards messages with WARNING orINFORMATION priority. Settinglog_error_suppression_list has no effect because all error codes it might suppress are already discarded due to thelog_error_verbosity setting.