The log_filter_internal
log filter component implements a simple form of log filtering based on error event priority and error code. log_filter_internal
日志筛选器组件实现了一种基于错误事件优先级和错误代码的简单形式的日志过滤。To affect how 若要影响log_filter_internal
permits or suppresses error, warning, and information events intended for the error log, set the log_error_verbosity
and log_error_suppression_list
system variables.log_filter_internal
允许或禁止针对错误日志的错误、警告和信息事件的方式,请设置log_error_verbosity
和log_error_pression_list
系统变量。
log_filter_internal
is built in and enabled by default. log_filter_internal
内置并默认启用。If this filter is disabled, 如果禁用此筛选器,则log_error_verbosity
and log_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
). log_error_verbosity
和log_error_suppression_list
无效,因此必须根据需要使用另一个筛选器服务执行筛选(例如,使用log_filter_dragnet
时使用单独的筛选器规则)。For information about filter configuration, see Section 5.4.2.1, “Error Log Configuration”.有关筛选器配置的信息,请参阅第5.4.2.1节,“错误日志配置”。
Events intended for the error log have a priority of 用于错误日志的事件具ERROR
, WARNING
, or INFORMATION
. The log_error_verbosity
system variable controls verbosity based on which priorities to permit for messages written to the log, as shown in the following table.ERROR
、WARNING
或INFORMATION
的优先级。log_error_verbosity
系统变量根据允许写入日志的消息的优先级控制详细信息,如下表所示。
log_error_verbosity | |
---|---|
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. log_error_verbosity
为2或更大,则服务器会记录关于对基于语句的日志记录不安全的语句的消息。If the value is 3, the server logs aborted connections and access-denied errors for new connection attempts. 如果值为3,则服务器会记录新连接尝试的中止连接和拒绝访问错误。See Section B.3.2.9, “Communication Errors and Aborted Connections”.请参阅第B.3.2.9节,“通信错误和中止的连接”。
If you use replication, a 如果使用复制,建议log_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.log_error_verbosity
值为2或更大,以获取有关正在发生的情况的更多信息,例如有关网络故障和重新连接的消息。
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.log_error_verbosity
为2或更大,则复制副本会向错误日志打印消息,以提供有关其状态的信息,例如二进制日志和中继日志坐标,它在哪里开始作业,何时切换到另一个中继日志,何时断开连接后重新连接,等等。
There is also a message priority of 还有一个SYSTEM
that is not subject to verbosity filtering. SYSTEM
的消息优先级不受详细信息筛选的约束。System messages about non-error situations are printed to the error log regardless of the 无论log_error_verbosity
value. log_error_verbosity
值是多少,有关非错误情况的系统消息都会打印到错误日志中。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”. 在MySQL错误日志中,系统消息被标记为“系统”。其他日志接收器可能遵循也可能不遵循相同的约定,并且在生成的日志中,系统消息可能会被分配用于信息优先级的标签,例如“注释”或“信息”。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.如果根据消息标签对日志记录应用任何其他筛选或重定向,则系统消息不会覆盖您的筛选器,而是以与其他消息相同的方式处理。
The log_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
or INFORMATION
. log_error_suppression_list
系统变量适用于用于错误日志的事件,并指定在优先级为WARNING
或INFORMATION
的情况下要抑制哪些事件。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 of ERROR
or SYSTEM
.log_error_suppression_list
不会抑制优先级为ERROR
或SYSTEM
的消息。
The log_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. log_error_suppression_list
值可以是不进行抑制的空字符串,也可以是指示要抑制的错误代码的一个或多个逗号分隔值的列表。Error codes may be specified in symbolic or numeric form. A numeric code may be specified with or without the 错误代码可以以符号或数字形式指定。数字代码可以指定带有或不带有MY-
prefix. MY-
前缀。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:尽管要抑制的代码可以用符号或数字形式表示,但每个代码的数值必须在允许的范围内:
1 to 999: Global error codes that are used by the server as well as by clients.1到999:服务器和客户端使用的全局错误代码。
10000 and higher: Server error codes intended to be written to the error log (not sent to clients).10000及更高版本:打算写入错误日志的服务器错误代码(不发送给客户端)。
In addition, each error code specified must actually be used by MySQL. 此外,指定的每个错误代码实际上都必须由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 the 试图指定一个不在允许范围内或在允许范围但MySQL未使用的代码会产生错误,并且log_error_suppression_list
value remains unchanged.log_error_pression_list
值保持不变。
For information about error code ranges and the error symbols and numbers defined within each range, see Section B.1, “Error Message Sources and Elements”, and MySQL 8.0 Error Message Reference.有关错误代码范围以及每个范围内定义的错误符号和数字的信息,请参阅第B.1节,“错误消息源和元素”和MySQL 8.0错误消息参考。
The server can generate messages for a given error code at differing priorities, so suppression of a message associated with an error code listed in 服务器可以以不同的优先级为给定的错误代码生成消息,因此对与log_error_suppression_list
depends on its priority. log_error_pression_list
中列出的错误代码相关联的消息的抑制取决于其优先级。Suppose that the variable has a value of 假设变量的值为'ER_PARSER_TRACE,MY-010001,10002'
. 'ER_PARSER_TRACE,MY-010001,10002'
。Then 那么log_error_suppression_list
has these effects on messages for those codes:log_error_pression_list
会对这些代码的消息产生以下影响:
Messages generated with a priority of 优先级为WARNING
or INFORMATION
are suppressed.WARNING
或INFORMATION
的消息将被抑制。
Messages generated with a priority of 优先级为ERROR
or SYSTEM
are not suppressed.ERROR
或SYSTEM
的消息不会被抑制。
The effect of log_error_verbosity
combines with that of log_error_suppression_list
. Consider a server started with these settings:log_error_verbosity
的效果与log_error_pression_list
的效果相结合。考虑使用以下设置启动的服务器:
[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
or WARNING
priority and discards messages with INFORMATION
priority. log_error_verbosity
允许具有ERROR
或WARNING
优先级的消息,并丢弃具有INFORMATION
优先级的消息。Of the nondiscarded messages, 在未丢弃的消息中,log_error_suppression_list
discards messages with WARNING
priority and any of the named error codes.log_error_pression_list
将丢弃具有WARNING
优先级的消息和任何命名的错误代码。
The 示例中显示的log_error_verbosity
value of 2 shown in the example is also its default value, so the effect of this variable on INFORMATION
messages is as just described by default, without an explicit setting. log_error_verbosity
值2也是其默认值,因此该变量对INFORMATION
消息的影响与默认情况下描述的一样,没有显式设置。You must set 如果您希望log_error_verbosity
to 3 if you want log_error_suppression_list
to affect messages with INFORMATION
priority.log_error_uppression_list
影响具有INFORMATION
优先级的消息,则必须将log_error_verbosity
设置为3。
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
or INFORMATION
priority. log_error_verbosity
允许具有ERROR
优先级的消息,并丢弃具有WARNING
或INFORMATION
优先级的消息。Setting 设置log_error_suppression_list
has no effect because all error codes it might suppress are already discarded due to the log_error_verbosity
setting.log_error_oppression_list
无效,因为它可能抑制的所有错误代码都已由于log_error_verbosity
设置而被丢弃。