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 ...
- redirect console messages to stdout instead of stderr.
- not log any messages.
- log to different filenames than "mysqlrouter.log"
Goal
Allow user to:
- configure the filename that's used by the
filelog - configure output device consolelog messages are written to
- configure the filename that's used by the
Leave existing, supported behaviour unchanged.
- FR1
-
[logger],[filelog]MUST acceptfilenameoption;[consolelog]MUST accept thedestinationoption - FR2
-
For
[logger]and[filelog]thefilenameoption MUST be a filename, not a path - FR3
-
[filelog]MUST build the path of the logfile by appending the filename to the value of thelogging_folderoption - FR4
-
If the
filenameoption is not specified or empty in[filelog], the[filelog]MUST use thefilenamevalue 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
destinationof[consolelog]is not set or empty, consolelog MUST log messages toSTDERR. - FR7
-
For
[consolelog]thedestinationoption must be an existing device, and the consolelog MUST open it and write messages to it. - FR8
-
Router shall not report a warning if
filenameis 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
filenamespecified for[logger]or[filelog]is not a file - FR10
-
Router MUST fail and report an error if the
destinationspecified for[consolelog]is not a device
New Configuration File Options
[logger].filename-
- type:
string - default: unset
- default value for
[filelog].filename
- type:
[filelog].filename-
- type:
string - default: for MySQL Router,
mysqlrouter.log - filename-part of the logfilename. Appended to
logging_folder.
- type:
[consolelog].destination-
- type:
string - default: stderr
- name of a device to log to, like
/dev/null,NUL, ...
- type:
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
Copyright (c) 2000, 2025, Oracle Corporation and/or its affiliates. All rights reserved.