WL#13838: User configurable router log filename

Affects: Server-8.0   —   Status: Complete

Motivation

Current behaviour

Since WL#12733 MySQL Router allows users to configure logging:

  • log-sinks: filelog, consolelog, eventlog, syslog
  • log-domains: sql, main, ...

By default, messages get send to the filelog when logging_folder is not empty, and consolelog otherwise.

The filelog appends messages to {logging_folder}/mysqlrouter.log and supports log-rotation via SIGHUP.

The consolelog sends messages to stderr. The consolelog ignore logrotation requests.

User Stories

As a sysadmin I want MySQL Router to ...

  1. redirect console messages to stdout instead of stderr.
  2. not log any messages.
  3. log to different filenames than "mysqlrouter.log"

Goal

  1. Allow user to:

    • configure the filename that's used by the filelog
    • configure output device consolelog messages are written to
  2. Leave existing, supported behaviour unchanged.

FR1
[logger], [filelog] MUST accept filename option; [consolelog] MUST accept the destination option
FR2
For [logger] and [filelog] the filename option MUST be a filename, not a path
FR3
[filelog] MUST build the path of the logfile by appending the filename to the value of the logging_folder option
FR4
If the filename option is not specified or empty in [filelog], the [filelog] MUST use the filename value specified in the [logger] section as filename if that is set and not empty.
FR5
If the filename of [filelog] is empty after FR3 and FR4 are applied, it MUST use a default filename (for MySQL Router: mysqlrouter.log).
FR6
If the destination of [consolelog] is not set or empty, consolelog MUST log messages to STDERR.
FR7
For [consolelog] the destination option must be an existing device, and the consolelog MUST open it and write messages to it.
FR8
Router shall not report a warning if filename is specified in the [logger] configuration, but no file-based logger is actually in use

Failure scenarios

FR9
Router MUST fail and report an error if the filename specified for [logger] or [filelog] is not a file
FR10
Router MUST fail and report an error if the destination specified for [consolelog] is not a device

New Configuration File Options

[logger].filename
  • type: string
  • default: unset
  • default value for [filelog].filename
[filelog].filename
  • type: string
  • default: for MySQL Router, mysqlrouter.log
  • filename-part of the logfilename. Appended to logging_folder.
[consolelog].destination
  • type: string
  • default: stderr
  • name of a device to log to, like /dev/null, NUL, ...

Examples

Example: log to {logger_folder}/mysqlrouter.log

The default behaviour needs no configuration.

# no configuration needed, use defaults only

Example: log to {logging_folder}/{filename}

As the file is built from logging_folder and filename, one can use:

[logger]
filename=error.log

Or specifying more parts:

[DEFAULT]
logging_folder=/some/base/path/

[logger]
filename=error.log

Or if multiple filelog sinks are used and each should go to another file:

[DEFAULT]
logging_folder=/some/base/path/

[filelog:a]
filename=a.log

[filelog:b]
filename=b.log

Example: log to /dev/null

[DEFAULT]
logging_folder=

[consolelog]
destination=/dev/null