|
| 1 | +--- |
| 2 | +title: 'Error logs - Azure Database for MySQL - Flexible Server' |
| 3 | +description: This article describes the error logs feature for Azure Database for MySQL - Flexible Server. |
| 4 | +ms.service: mysql |
| 5 | +ms.subservice: flexible-server |
| 6 | +ms.topic: conceptual |
| 7 | +author: code-sidd |
| 8 | +ms.author: sisawant |
| 9 | +ms.date: 12/15/2023 |
| 10 | +--- |
| 11 | + |
| 12 | +# Error logs in Azure Database for MySQL - Flexible Server (Preview) |
| 13 | + |
| 14 | +[!INCLUDE[applies-to-mysql-flexible-server](../includes/applies-to-mysql-flexible-server.md)] |
| 15 | + |
| 16 | +In Azure Database for MySQL - Flexible Server, the error log is available to users to configure and access. Error logs in MySQL gather diagnostic messages during server startup and shutdown, and while the server is running, information that can help proactive troubleshooting. For more information about the MySQL error log, see the [Error log](https://dev.mysql.com/doc/refman/8.0/en/error-log.html) section in the MySQL documentation. |
| 17 | +Under Preview phase, error logs are available under Server logs only, error logs **can't be emitted** to [Azure Diagnostic logs](./../../azure-monitor/essentials/platform-logs-overview.md). |
| 18 | + |
| 19 | +>[!Note] |
| 20 | +>The Error Log feature is accessible for new servers created after *November 14, 2023, 00:00 UTC*. For existing servers, this feature will become available following their scheduled maintenance in January 2024. [Learn more about scheduled maintainence](./concepts-maintenance.md) on your server. To enable the Error Log feature on existing servers, before the scheduled maintainence, kindly contact us via [support ticket](./../../azure-portal/supportability/how-to-manage-azure-support-request.md). |
| 21 | +
|
| 22 | +In Azure Database for MySQL - Flexible Server, enabling the error log under [Server logs](./concepts-monitoring.md#server-logs) in the Azure portal records details in multiple files named using the syntax *mysql-error-servername-timestamp.log*. In the file name, the timestamp (in GMT/UTC) associated with when the file was generated is appended, identifying the specific time that that log entries were recorded. For more information, see [Server logs retention.](./concepts-monitoring.md#server-logs) |
| 23 | + |
| 24 | +## Enabling error logs (Preview) |
| 25 | + |
| 26 | +Users can access and configure the error logs in Azure Database for MySQL – Flexible Server via the Server logs feature, which can be enabled using the [Azure portal](./how-to-server-logs-portal.md#enable-server-logs) or [Azure CLI](./how-to-server-logs-cli.md). |
| 27 | +After the feature is enabled, your MySQL flexible server starts capturing events and writes them to a series of files saved as activity occurs. |
| 28 | + |
| 29 | +To enable Error logs, perform the following steps. |
| 30 | +1. In the Azure portal, navigate to your flexible server, and then, under Monitoring, select Server logs. |
| 31 | +2. Under Server logs, select the Enable check box, which enables the server logs features |
| 32 | +3. Under Select logs to enable, select the Error logs check box. |
| 33 | + |
| 34 | + :::image type="content" source="./media/concepts-error-logs/1-concepts-error-logs.png" alt-text="Screenshot of portal view showing Error Logs - Enable."::: |
| 35 | + |
| 36 | +4. Select Save to proceed with deployment. |
| 37 | + |
| 38 | + |
| 39 | +You can also enable Error logs on your Azure Database for MySQL flexible server by [enabling the server parameter](./how-to-configure-server-parameters-portal.md) named *“error_server_log_file”* via the Server parameters pane or via the [Azure CLI](./how-to-configure-server-parameters-cli.md). |
| 40 | + |
| 41 | +Ensure that the [Server logs feature](./how-to-server-logs-portal.md#enable-server-logs) is activated by selecting the *Enable* checkbox in the Server logs pane. Alternatively, set the server parameter "log_output" to FILE to enable server logs. Failure to perform either of these actions result in FILE logging not being enabled for your Azure Database for MySQL flexible server. |
| 42 | + |
| 43 | +## Accessing error logs |
| 44 | +You can download the error logs for further analysis of your Azure Database for MySQL flexible server. To download the logs, in the Azure portal, navigate to the Server logs section, and then select the Error logs tab, as shown. |
| 45 | + - Under **Name**, select the log file you want to download, and then, under **Action**, select **Download**. |
| 46 | + |
| 47 | + :::image type="content" source="./media/concepts-error-logs/2-concepts-error-logs.png" alt-text="Screenshot of portal view showing Error Logs - Download."::: |
| 48 | + |
| 49 | + - To download *multiple log files* at one time, under **Name**, select the files you want to download, select **Download**. |
| 50 | + |
| 51 | + :::image type="content" source="./media/concepts-error-logs/3-concepts-error-logs.png" alt-text="Screenshot of portal view showing Error Logs - Multiple Downloads."::: |
| 52 | + |
| 53 | + |
| 54 | +### Access error logs using Azure CLI |
| 55 | +You can list the server logs from your flexible server by using the following command. |
| 56 | +```azurecli |
| 57 | +az mysql flexible-server server-logs list --resource-group <myresourcegroup> --server-name <server_name> --out table |
| 58 | +``` |
| 59 | + |
| 60 | +To download the mentioned server logs to your current directory, use the following command: |
| 61 | +```azurecli |
| 62 | +az mysql flexible-server server-logs download --resource-group <myresourcegroup> --server-name <server_name> --name <mysql-error-<server_name>-<timestamp>.log> |
| 63 | +``` |
| 64 | + |
| 65 | +For more information, see [how to download the server logs files](./how-to-server-logs-portal.md#download-server-logs) via the Azure portal or via the [Azure CLI](./how-to-server-logs-cli.md#downloading-server-logs-using-azure-cli). |
| 66 | + |
| 67 | + |
| 68 | +### Error logs under server logs retention |
| 69 | +When logging is enabled for an Azure Database for MySQL - Flexible Server, logs are available up to seven days from their creation. If the total size of the available logs exceeds 7 GB, then the oldest files are deleted until space is available. The 7-GB storage limit for server logs is available free of cost and can't be extended. Logs are rotated every 24 hours or 500 MB, whichever comes first. |
| 70 | +Importantly, you can download the logs before rotation, ensuring they have access to valuable server logs at any point within the retention period. |
| 71 | +For more detailed information on log rotation schedules and storage limits for various log types, refer to the [documentation on Server log retention](./concepts-monitoring.md#server-logs). |
| 72 | + |
| 73 | + |
| 74 | +## Frequently asked questions |
| 75 | + |
| 76 | +*Question*: My error logs contain the note as shown, what does this mean? |
| 77 | + |
| 78 | +`[Note] [Server] Access denied for user ''@'xx.xx.xx.X' (using password: NO).` |
| 79 | + |
| 80 | +*Answer*: This note indicates that an attempt to connect to your MySQL server was unsuccessful due to incorrect or missing authentication details. Specifically, the username provided is empty(''@'xx.xx.xx.X') and no password was entered (using password: NO). This note could indicate an unauthorized attempt to access your database. |
| 81 | +If your server is publicly accessible, it remains exposed to the internet and can be a target for unauthorized access attempts. To enhance the security of your Azure Database for MySQL flexible server, [disable public access](./concepts-networking-private-link.md#deny-public-access) or [limit access using firewall rules.](./concepts-networking-public.md#firewall-rules). |
| 82 | + |
| 83 | +## Next steps |
| 84 | +- How to enable server logs feature via Azure portal. [Learn more](./how-to-server-logs-portal.md) |
| 85 | +- How to enable server logs feature via Azure CLI. [Learn more](./how-to-server-logs-cli.md) |
0 commit comments