---
title: "PostgreSQL cluster logs"
sidebar_label: "Cluster logs"
sidebar_position: 11
description: "How to enable PostgreSQL cluster logging, how to get logs, and how to disable cluster logging"
---

import Formbricks from '@theme/MDXComponents/Formbricks';
import EnableLogs from '@site/i18n/en/docusaurus-plugin-content-docs/current/_partials/managed-databases/common/enable-logs.mdx';
import DisableLogs from '@site/i18n/en/docusaurus-plugin-content-docs/current/_partials/managed-databases/common/disable-logs.mdx';
import { CustomTable } from '@selectel/docux/components';

# PostgreSQL cluster logs

Logging is handled by the [Logs](/logs/) service. For more information on how the service works and its pricing, see the [General information about the Logs service](/logs/about-logs.mdx) guide. You can check the availability of the Logs service in different regions in the [Availability Matrix](/infrastructure/product-availability-by-location.mdx#logs).

For a PostgreSQL Managed Database cluster, events in the PostgreSQL databases and the PgBouncer connection pooler are logged.

To collect cluster logs using the Logs service, you must [enable logging](#enable-logs). [You can retrieve logs](#get-logs) in the control panel, via API requests, or using the [AWS CLI](/logs/tools/aws-cli.mdx). If you no longer need to collect logs, you can [disable logging](#disable-logs).

Logs are stored for 30 days.

Read more about logging in PostgreSQL databases in the [Error Reporting and Logging](https://www.postgresql.org/docs/current/runtime-config-logging.html) section of the PostgreSQL documentation.

## Enable logging \{#enable-logs}

<EnableLogs DatabaseName="PostgreSQL" ArticleName="Monitoring of the cluster, nodes and databases PostgreSQL" slug="postgresql" />

## Get logs \{#get-logs}

Use the [Get logs](/logs/manage/get-logs.mdx) instruction in the Logs section.

event streams `postgresql.log-<instance_id>` and `pgbouncer.log-<instance_id>` will be created for a Managed Database for PostgreSQL cluster, where `<instance_id>` is the PostgreSQL cluster node ID.

See the description of [log fields](#fields) for a PostgreSQL cluster.

## Log fields \{#fields}

<CustomTable>
  <table>
    <tbody>
      <tr>
        <th>\_HOSTNAME</th><td>cluster node name in `dbaas-<instance_id>` format, where `<instance_id>` is the PostgreSQL cluster node ID</td>
      </tr>

      <tr>
        <th>SYSLOG\_IDENTIFIER</th><td>Log source name</td>
      </tr>

      <tr>
        <th>SYSLOG\_TIMESTAMP</th><td>Event timestamp in the log</td>
      </tr>

      <tr>
        <th>MESSAGE</th><td>Description of the event provided by the log source</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

## Disable logging \{#disable-logs}

<DisableLogs />

<Formbricks />
