title | description | ms.service | ms.subservice | ms.topic | ms.author | author | ms.devlang | ms.custom | ms.date |
---|---|---|---|---|---|---|---|---|---|
Manage logs - Azure CLI - Azure Database for PostgreSQL - Single Server |
This article describes how to configure and access the server logs (.log files) in Azure Database for PostgreSQL - Single Server by using the Azure CLI. |
postgresql |
single-server |
how-to |
sunila |
sunilagarwal |
azurecli |
devx-track-azurecli |
06/24/2022 |
[!INCLUDE applies-to-postgresql-single-server]
[!INCLUDE azure-database-for-postgresql-single-server-deprecation]
You can download the PostgreSQL server error logs by using the command-line interface (Azure CLI). However, access to transaction logs isn't supported.
To step through this how-to guide, you need:
- Azure Database for PostgreSQL server
- The Azure CLI command-line utility or Azure Cloud Shell in the browser
You can configure the server to access query logs and error logs. Error logs can have auto-vacuum, connection, and checkpoint information.
- Turn on logging.
- To enable query logging, update log_statement and log_min_duration_statement.
- Update retention period.
For more information, see Customizing server configuration parameters.
To list the available log files for your server, run the az postgres server-logs list command.
You can list the log files for server mydemoserver.postgres.database.azure.com under the resource group myresourcegroup. Then direct the list of log files to a text file called log_files_list.txt.
az postgres server-logs list --resource-group myresourcegroup --server mydemoserver > log_files_list.txt
With the az postgres server-logs download command, you can download individual log files for your server.
Use the following example to download the specific log file for the server mydemoserver.postgres.database.azure.com under the resource group myresourcegroup to your local environment.
az postgres server-logs download --name 20170414-mydemoserver-postgresql.log --resource-group myresourcegroup --server mydemoserver
To download all available logs at once.
az postgres server-logs list -g [resource-group] -s [server-name] --query '[].{Name:name}' -o tsv |xargs -I {} az postgres server-logs download -g [resource-group] -s [server-name] -n {}
- To learn more about server logs, see Server logs in Azure Database for PostgreSQL.
- For more information about server parameters, see Customize server configuration parameters using Azure CLI.