Rechercher dans le manuel MySQL
5.4.2.1 Error Log Component Configuration
In MySQL 8.0, error logging uses the MySQL component architecture described at Section 5.5, “MySQL Server Components”. The error log subsystem consists of components that perform log event filtering and writing, as well as a system variable that configures which components to enable to achieve the desired logging result.
This section discusses how to select components for error logging. For instructions specific to the system log and JSON log writers, see Section 5.4.2.3, “Error Logging to the System Log”, and Section 5.4.2.4, “Error Logging in JSON Format”. For additional details about all available log components, see Section 5.5.3, “Error Log Components”.
Component-based error logging offers these features:
Log events can be filtered by filter components to affect the information available for writing.
Log events are output by sink (writer) components. Multiple sink components can be enabled, to write error log output to multiple destinations.
Built-in filter and writer components combine to implement the default error log format.
A loadable writer enables logging to the system log.
A loadable writer enables logging in JSON format.
System variables control which log components to enable and the rules for filtering log events.
The log_error_services
system
variable controls which log components to enable for error
logging. The variable may contain a list with 0, 1, or many
elements. In the latter case, elements may be delimited by
semicolon or (as of MySQL 8.0.12) comma, optionally followed by
space. A given setting cannot use both semicolon and comma
separators. Component order is significant because the server
executes components in the order listed.
By default, log_error_services
has this value:
- +----------------------------------------+
- +----------------------------------------+
- | log_filter_internal; log_sink_internal |
- +----------------------------------------+
That value indicates that log events first pass through the
built-in filter component,
log_filter_internal
, then through the
built-in log writer component,
log_sink_internal
. A filter modifies log
events seen by components named later in the
log_error_services
value. A
sink is a destination for log events. Typically, a sink
processes log events into log messages that have a particular
format and writes these messages to its associated output, such
as a file or the system log.
If log_error_services
is
assigned a value that contains no writer components, no log
output is written from that point.
The final component in the
log_error_services
value
should be a writer. If the final component is a filter, it has
no effect because the filtered events are not sent to any
writer.
The combination of log_filter_internal
and
log_sink_internal
implements the default
error log filtering and output behavior. The action of these
components is affected by other server options and system
variables:
The output destination is determined by the
--log-error
option (and, on Windows,--pid-file
and--console
). These determine whether to write error messages to the console or a file and, if to a file, the error log file name. See Section 5.4.2.2, “Default Error Log Destination Configuration”.The
log_error_verbosity
system variable affects which types of log eventslog_filter_internal
permits or suppresses. See Section 5.4.2.5, “Error Log Filtering”.
To change the set of log components used for error logging, load
components as necessary and modify the
log_error_services
value.
Adding or removing log components is subject to these
constraints:
To enable a log component, first load it using
INSTALL COMPONENT
(unless it is built in or already loaded), then list the component in thelog_error_services
value.For a component to be permitted in the
log_error_services
value, it must be known. A component is known if it is built in, or if it is loadable and has been loaded usingINSTALL COMPONENT
. Attempts to name an unknown component at server startup causelog_error_services
to be set to its default value. Attempts to name an unknown component at runtime produce an error and thelog_error_services
value remains unchanged.To disable a log component, remove it from the
log_error_services
value. Then, if the component is loadable and you also want to unload it, useUNINSTALL COMPONENT
.Attempts to use
UNINSTALL COMPONENT
to unload a loadable component that is still named in thelog_error_services
value produce an error.
For example, to use the system log writer
(log_sink_syseventlog
) instead of the default
writer (log_sink_internal
), first load the
writer component, then modify the
log_error_services
value:
- INSTALL COMPONENT 'file://component_log_sink_syseventlog';
The URN to use for loading a log component with
INSTALL COMPONENT
is the
component name prefixed with
file://component_
. For example, for the
log_sink_syseventlog
component, the
corresponding URN is
file://component_log_sink_syseventlog
.
It is possible to configure multiple log writers to send output
to multiple destinations. To enable the system log writer in
addition to (rather than instead of) the default writer, set the
log_error_services
value like
this:
To revert to using only the default writer and unload the system log writer, execute these statements:
- UNINSTALL COMPONENT 'file://component_log_sink_syseventlog';
To configure a log component to be enabled at each server startup, use this procedure:
If the component is loadable, load it using
INSTALL COMPONENT
. Loading the component registers it in themysql.component
system table so that the server loads it automatically for subsequent startups.Set the
log_error_services
value at startup to include the component name. Set the value either in the servermy.cnf
file, or useSET PERSIST
, which sets the value for the running MySQL instance and also saves the value to be used for subsequent server restarts; see Section 13.7.5.1, “SET Syntax for Variable Assignment”. A value set inmy.cnf
takes effect at the next restart. A value set usingSET PERSIST
takes effect immediately, and for subsequent restarts.
Suppose that you want to configure, for every server startup,
use of the JSON log writer (log_sink_json
) in
addition to the built-in log filter and writer
(log_filter_internal
,
log_sink_internal
). First load the JSON
writer if it is not loaded:
- INSTALL COMPONENT 'file://component_log_sink_json';
Then set log_error_services
to
take effect at server startup. You can set it in
my.cnf
:
[mysqld]
log_error_services='log_filter_internal; log_sink_internal; log_sink_json'
Or you can set it using
SET
PERSIST
:
The order of components named in
log_error_services
is
significant, particularly with respect to the relative order of
filters and writers. Consider this
log_error_services
value:
log_filter_internal; log_sink_1; log_sink_2
In this case, log events pass to the built-in filter, then to the first writer, then to the second writer. Both writers receive filtered log events.
Compare that to this
log_error_services
value:
log_sink_1; log_filter_internal; log_sink_2
In this case, log events pass to the first writer, then to the built-in filter, then to the second writer. The first writer receives unfiltered events. The second writer receives filtered events. You might configure error logging this way if you want one log that contains messages for all log events, and another containing messages only for a subset of log events.
Traduction non disponible
Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-error-log-component-configuration.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.