MySQL Router 8.0  /  MySQL Router Application  /  Using the Logging Feature

5.2 Using the Logging Feature

The logging feature can be handy for developing and testing your application and deployment of the MySQL Router. To use logging, enable the logging level option in the configuration file under the section named [logger]. For example:

level = INFO

Set the log file's location with the logging_folder option, defined as a directory path under the [DEFAULT] section in the configuration file. The logging file is named mysqlrouter.log. For example:

# Logs are sent to /path/to/folder/mysqlrouter.log
logging_folder = /path/to/folder

level = DEBUG

Setting logging_folder to an empty string sends logs to the console (stdout).

Two common logging levels are INFO (default) and DEBUG:

  • INFO: includes informational messages like those shown above, and is the default mode

  • DEBUG: includes messages generated inside Router's source code for use in diagnostics. The DEBUG mode presents verbose information concerning the inner workings of Router. While it may not be of interest to the application, use of the DEBUG mode may be helpful if you encounter a problem or when Router is not behaving as you expect.

The following example shows what the messages look like for the DEBUG logging level; compare the INFO and DEBUG messages:

2019-04-07 18:25:56 INFO    [0x700009673000] Connections using ssl_mode 'PREFERRED'
2019-04-07 18:25:56 INFO    [0x700009673000] Connected with metadata server running on
2019-04-07 18:25:56 DEBUG   [0x700009673000] Updating metadata information for cluster 'devCluster'
2019-04-07 18:25:56 DEBUG   [0x700009673000] Updating replicaset status from GR for 'default'
2019-04-07 18:25:56 DEBUG   [0x700009673000] Replicaset 'default' has 3 members in metadata, 3 in status table
2019-04-07 18:25:56 DEBUG   [0x700009673000] End updating replicaset for 'default'
2019-04-07 18:25:56 INFO    [0x700009673000] Changes detected in cluster 'devCluster' after metadata refresh
2019-04-07 18:25:56 INFO    [0x700009673000] Metadata for cluster 'devCluster' has 1 replicasets: