|
| 1 | +--- |
| 2 | +title: 'How to enable and download server logs for Azure Database for MySQL - Flexible Server' |
| 3 | +description: This article describes how to download and list server logs using Azure portal. |
| 4 | +ms.service: mysql |
| 5 | +ms.subservice: flexible-server |
| 6 | +ms.topic: conceptual |
| 7 | +author: code-sidd |
| 8 | +ms.author: sisawant |
| 9 | +ms.date: 08/05/2022 |
| 10 | +--- |
| 11 | +# Enable, list and download server logs for Azure Database for MySQL - Flexible Server |
| 12 | + |
| 13 | +[!INCLUDE[applies-to-mysql-flexible-server](../includes/applies-to-mysql-flexible-server.md)] |
| 14 | + |
| 15 | +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. |
| 16 | +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. |
| 17 | +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. |
| 18 | + |
| 19 | +In this tutorial, you’ll learn how to: |
| 20 | +- Enable the server logs feature. |
| 21 | +- Disable the server logs feature. |
| 22 | +- Download server log files. |
| 23 | + |
| 24 | +## Prerequisites |
| 25 | + |
| 26 | +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](./quickstart-create-server-portal.md). |
| 27 | + |
| 28 | +## Enable Server logs |
| 29 | + |
| 30 | +To enable the server logs feature, perform the following steps. |
| 31 | + |
| 32 | +1. In the [Azure portal](https://portal.azure.com), select your MySQL flexible server. |
| 33 | + |
| 34 | +2. On the left pane, under **Monitoring**, select **Server logs**. |
| 35 | + |
| 36 | + :::image type="content" source="./media/how-to-server-logs-portal/1-how-to-serverlog.png" alt-text="Screenshot showing Azure Database for My SQL - Server Logs."::: |
| 37 | + |
| 38 | +3. To enable server logs, under **Server logs**, select **Enable**. |
| 39 | + |
| 40 | + :::image type="content" source="./media/how-to-server-logs-portal/2-how-to-serverlog.png" alt-text="Screenshot showing Enable Server Logs."::: |
| 41 | + |
| 42 | +>[!Note] |
| 43 | +> You can also enable server logs in the Azure portal, on the [Server parameters](./how-to-configure-server-parameters-portal.md) pane for your server, by setting the value of the log_output parameter to FILE. |
| 44 | +> For more information on the log_output parameter, in the MySQL documentation, see topic Server System Variables ([version 5.7](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_log_output) or [version 8.0](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_log_output)). |
| 45 | +
|
| 46 | +4. To enable the slow_query_log log, under **Select logs to enable**, select **slow_query_log**. |
| 47 | + |
| 48 | + :::image type="content" source="./media/how-to-server-logs-portal/3-how-to-serverlog.png" alt-text="Screenshot showing select slow log - Server Logs."::: |
| 49 | + |
| 50 | +To configure slow_logs on your Azure Database for MySQL flexible server, see [Query Performance Insight.](./tutorial-query-performance-insights.md) |
| 51 | + |
| 52 | + |
| 53 | +## Download Server logs |
| 54 | + |
| 55 | +To download server logs, perform the following steps. |
| 56 | +> [!Note] |
| 57 | +> After enabling logs, the log files will be available to download after few minutes. |
| 58 | +
|
| 59 | +1. Under **Name**, select the log file you want to download, and then, under **Action**, select **Download**. |
| 60 | + |
| 61 | + :::image type="content" source="./media/how-to-server-logs-portal/4-how-to-serverlog.png" alt-text="Screenshot showing Server Logs - Download."::: |
| 62 | + |
| 63 | + 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. |
| 64 | + |
| 65 | + :::image type="content" source="./media/how-to-server-logs-portal/5-how-to-serverlog.png" alt-text="Screenshot showing server Logs - HA logs."::: |
| 66 | + |
| 67 | +2. To download multiple log files at one time, under **Name**, select the files you want to download, and then above **Name**, select **Download**. |
| 68 | + |
| 69 | + :::image type="content" source="./media/how-to-server-logs-portal/6-how-to-serverlog.png" alt-text="Screenshot showing server Logs - Download all."::: |
| 70 | + |
| 71 | + |
| 72 | +## Disable Server Logs |
| 73 | + |
| 74 | +1. From your Azure portal, select Server logs from Monitoring server pane. |
| 75 | + |
| 76 | +2. For disabling Server logs to file, Uncheck Enable. (The setting will disable logging for all the log_types available) |
| 77 | + |
| 78 | + :::image type="content" source="./media/how-to-server-logs-portal/7-how-to-serverlog.png" alt-text="Screenshot showing server Logs - Disable."::: |
| 79 | + |
| 80 | +3. Select Save |
| 81 | + |
| 82 | + :::image type="content" source="./media/how-to-server-logs-portal/8-how-to-serverlog.png" alt-text="Screenshot showing server Logs - Save."::: |
| 83 | + |
| 84 | + |
| 85 | +## Next steps |
| 86 | +- Learn more about [How to enable slow query logs](./tutorial-query-performance-insights.md#configure-slow-query-logs-by-using-the-azure-portal) |
| 87 | +- List and download [Server logs using Azure CLI](./how-to-server-logs-cli.md) |
0 commit comments