Enable, list and download server logs for Azure Database for MySQL - Flexible Server

APPLIES TO: Azure Database for MySQL - Flexible Server

You can use server logs to help monitor and troubleshoot an instance of Azure Database for MySQL - Flexible Server, and to gain detailed insights into the activities that have run on your servers. By default, the server logs feature in Azure Database for MySQL - Flexible Server is disabled. However, after you enable the feature, a flexible server starts capturing events of the selected log type and writes them to a file. You can then use the Azure portal or the Azure CLI to download the files to assist with your troubleshooting efforts. This article explains how to enable the server logs feature in Azure Database for MySQL - Flexible Server and download server log files. It also provides information about how to disable the feature.

In this tutorial, you’ll learn how to:

  • Enable the server logs feature.
  • Disable the server logs feature.
  • Download server log files.

Prerequisites

To complete this tutorial, you need an existing Azure Database for MySQL flexible server. If you need to create a new server, see Create an Azure Database for MySQL flexible server.

Enable Server logs

To enable the server logs feature, perform the following steps.

  1. In the Azure portal, select your MySQL flexible server.

  2. On the left pane, under Monitoring, select Server logs.

    Screenshot showing Azure Database for My SQL - Server Logs.

  3. To enable server logs, under Server logs, select Enable.

    Screenshot showing Enable Server Logs.

Note

You can also enable server logs in the Azure portal, on the Server parameters pane for your server, by setting the value of the log_output parameter to FILE. For more information on the log_output parameter, in the MySQL documentation, see topic Server System Variables (version 5.7 or version 8.0).

  1. To enable the slow_query_log log, under Select logs to enable, select slow_query_log.

    Screenshot showing select slow log - Server Logs.

To configure slow_logs on your Azure Database for MySQL flexible server, see Query Performance Insight.

Download Server logs

To download server logs, perform the following steps.

Note

After enabling logs, the log files will be available to download after few minutes.

  1. Under Name, select the log file you want to download, and then, under Action, select Download.

    Screenshot showing Server Logs - Download.

    For HA enabled Azure database for MySQL Flexible server, server logs for standby server can be identified by another four-letter identifier after the hostname of the server as shown below.

    Screenshot showing server Logs - HA logs.

  2. To download multiple log files at one time, under Name, select the files you want to download, and then above Name, select Download.

    Screenshot showing server Logs - Download all.

Disable Server Logs

  1. From your Azure portal, select Server logs from Monitoring server pane.

  2. For disabling Server logs to file, Uncheck Enable. (The setting will disable logging for all the log_types available)

    Screenshot showing server Logs - Disable.

  3. Select Save

    Screenshot showing server Logs - Save.

Next steps