Enable, list and download server logs for Azure Database for PostgreSQL - Flexible Server
APPLIES TO: Azure Database for PostgreSQL - Flexible Server
You can use server logs to help monitor and troubleshoot an instance of Azure Database for PostgreSQL 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 PostgreSQL flexible server is disabled. However, after you enable the feature, Azure Database for PostgreSQL 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 PostgreSQL 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 Azure Database for PostgreSQL flexible server instance. If you need to create a new server, see Create an Azure Database for PostgreSQL - Flexible Server.
Enable Server logs
To enable the server logs feature, perform the following steps.
In the Azure portal, select your Azure Database for PostgreSQL flexible server instance.
On the left pane, under Monitoring, select Server logs.
To enable server logs, under Server logs, select Enable.
To configure retention period (in days), choose the slider. Minimum retention 1 days and Maximum retention is 7 days.
Note
You can configure your server logs in the same way as above using the Server Parameters, setting the appropriate values for these parameters: logfiles.download_enable to ON to enable this feature, and logfiles.retention_days to define retention in days. Initially, server logs occupy data disk space for about an hour before moving to backup storage for the set retention period.
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.
Under Name, select the log file you want to download, and then, under Action, select Download.
To download multiple log files at one time, under Name, select the files you want to download, and then above Name, select Download.
Disable Server Logs
From your Azure portal, select Server logs from Monitoring server pane.
For disabling Server logs to file, Uncheck Enable. (The setting will disable logging for all the log_types available)
Select Save