Error logging in JSON format

To use the JSON format for logging, you need to load the JSON log writer called log_sink_json. You can use the built-in filter, log_filter_internal, for filtering:

  1. Install the JSON log writer:
mysql> INSTALL COMPONENT 'file://component_log_sink_json';Query OK, 0 rows affected (0.05 sec)
  1. Make it persistent across restarts:
mysql> SET PERSIST log_error_services = 'log_filter_internal; log_sink_json';Query OK, 0 rows affected (0.00 sec)
  1. The JSON log writer determines its output destination based on the default error log destination, which is given by the log_error system variable:
mysql> SHOW VARIABLES LIKE 'log_error';+---------------+---------------------------+| Variable_name | Value                     |+---------------+---------------------------+ ...

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.