从 Azure 门户配置和访问 Azure Database for PostgreSQL(单一服务器)日志Configure and access Azure Database for PostgreSQL - Single Server logs from the Azure portal

可以从 Azure 门户配置、列出和下载 Azure Database for PostgreSQL 日志You can configure, list, and download the Azure Database for PostgreSQL logs from the Azure portal.

必备条件Prerequisites

本文中的步骤要求具备 Azure Database for PostgreSQL 服务器The steps in this article require that you have Azure Database for PostgreSQL server.

配置日志记录Configure logging

配置对查询日志和错误日志的访问权限。Configure access to the query logs and error logs.

  1. 登录 Azure 门户Sign in to the Azure portal.

  2. 选择你的 Azure Database for PostgreSQL 服务器。Select your Azure Database for PostgreSQL server.

  3. 在边栏中的“监视”部分下,选择“服务器日志” 。Under the Monitoring section in the sidebar, select Server logs.

    “服务器日志”选项的屏幕截图

  4. 若要查看服务器参数,请选择“单击此处以启用日志并配置日志参数” 。To see the server parameters, select Click here to enable logs and configure log parameters.

  5. 更改需要调整的参数。Change the parameters that you need to adjust. 在此会话中所做的更改都突出显示为紫色。All changes you make in this session are highlighted in purple.

    更改参数之后,请选择“保存”。 After you have changed the parameters, select Save. 也可以放弃所做的更改。Or, you can discard your changes.

    “服务器参数”选项的屏幕截图

在“服务器参数” 页上,可以通过关闭该页来返回到日志列表。From the Server Parameters page, you can return to the list of logs by closing the page.

查看列表并下载日志View list and download logs

日志记录开始后,可以查看可用日志列表,并下载单个日志文件。After logging begins, you can view a list of available logs, and download individual log files.

  1. 打开 Azure 门户。Open the Azure portal.

  2. 选择你的 Azure Database for PostgreSQL 服务器。Select your Azure Database for PostgreSQL server.

  3. 在边栏中的“监视”部分下,选择“服务器日志” 。Under the Monitoring section in the sidebar, select Server logs. 此页将显示日志文件列表。The page shows a list of your log files.

    “服务器日志”页的屏幕截图,其中突出显示了日志列表

    提示

    日志的命名约定是 postgresql-yyyy-mm-dd_hh0000.logThe naming convention of the log is postgresql-yyyy-mm-dd_hh0000.log. 文件名中使用的日期和时间是发布日志的时间。The date and time used in the file name is the time when the log was issued. 每小时或达到 100 MB 大小时日志文件会轮换一次,以先达到的条件为准。The log files rotate every hour or 100 MB, whichever comes first.

  4. 如果需要,可使用搜索框快速缩小范围,以根据日期和时间找到特定日志。If needed, use the search box to quickly narrow down to a specific log, based on date and time. 搜索按日志名称进行。The search is on the name of the log.

    “服务器日志”页的屏幕截图,其中突出显示了搜索框和结果

  5. 若要下载单个日志文件,请选择表行中每个日志文件旁边的向下箭头图标。To download individual log files, select the down-arrow icon next to each log file in the table row.

    “服务器日志”页的屏幕截图,其中突出显示了向下箭头图标

后续步骤Next steps