WL#12733: Allow MySQLRouter to log to multiple log sinks.

Affects: Server-8.0   —   Status: Complete

Motivation

MySQL Router supports logging to different sinks:

  • console
  • file
  • syslog (unix only)
  • eventlog ("WL#9552 Windows Event Log Plugin", windows only)

Internally each log-sink and log-domain has its own log-level, but the configuration can only set the global log-level.

user story

  1. As a user I want to log all the messages to file (level=debug) and only errors to the eventlog (level=error).

Goal

  • allow to configure each log sink independently.

Functional Requirements

FR1
The user should have a way to configure multiple logger sinks in the configuration file
FR2
The supported sinks should be: consolelog, filelog, eventlog on Windows and syslog (on Unix-based OSes)
FR3
There should a way to set the log level for each of the sinks independently.
FR4
If a given sink is configured but does not have the log level specified, it should use the default one from the [logger] section, or if that one is missing too implicit default which is "warning"
FR5
Until the logging sinks get initialized the MySQLRouter should log to the console. That means that any logger configuration errors will be printed on the console as those are discovered during the logger initialization.
FR6
For the backward compatibility the old configuration files should be supported and handled in a way it were handled so far. If the [logger] section is missing or it does not specify the sinks we should log to the console (when the plugin_folder option is empty in the [DEFAULT] section) or to the file (when the plugin_folder option is NOT empty in the [DEFAULT] section).

Non-Functional Requirements

NFR1
All the logging related plugins shall be built-in to the router binary, so that the logging could start as soon as possible, before the external plugins loading etc.
NFR2
As all the logging plugins are built-in now there no longer should be syslog.so shipped for the Unix-based systems.

In order to be able to configure multiple logger sinks the [logger] section should now support "sinks" option. The following example configures the logger to use the file, console and the eventlog each using default log level configured in the [logger] section:

    [logger]
    level=debug
    sinks=consolelog,eventlog,filelog

To configure different levels per sink, the sinks has to have its own config section that will overwrite the default log level. In the following example console and eventlog sinks define their own log levels, while the filelog still uses the default one:

    [logger]
    level=debug
    sinks=consolelog,eventlog,filelog

    [consolelog]
    level=warning

    [eventlog]
    level=error

For he backward compatibilty if the [logger] section is missing or it does not contain the sinks option it should use the default sink which is "filelog" if the "logging_folder" option is not empty in the "[DEFAULT]" section or "consolelog" if the "logging_folder" is empty.

For example the following means logging ONLY to the console (which is default sink when logging_folder is empty) even tho there may be some other sink sections in the config file.

    [DEFAULT]
    logging_folder=

    [logger]
    level=debug

    [consolelog]
    level=warning

    [eventlog]
    level=error