# Read the server log

Search the PostgreSQL server log of every node for errors, slow statements and failed logins.

The log shows every node's PostgreSQL server log, newest first: errors with their statement, slow
statements, failed logins, a new leader's promotion and recovery after a crash. Lines are kept seven
days. Replace _ewdb-0123456789ab_ with your database's id.

## Prerequisites

- Permission for `rds:DescribeDBLogFiles`. The log carries statement text with its values, so
  reading it needs its own permission, and each read is recorded in the audit log. Without it the
  **Logs** tab is locked and names the action.
- Machines built with log shipping. Machines built before it keep their log on the machine, and the
  tab shows no lines.
- In the console, also `rds:DescribeDBInstances` to open the database's page (without it the page is
  not found).

## Read the log

**Console**
1. Open the database, then choose the **Logs** tab. It shows the last day, up to 500 lines.
2. (Optional) In the search box, enter text and press Enter.
3. (Optional) Choose a severity: **All**, **Errors**, **Warnings** or **Log**.

With nothing found, the tab says "No lines in the last day".

**CLI**
```sh
dcloud rds instances logs ewdb-0123456789ab --severity error --contains deadlock --limit 200
```

`--node` limits it to one node (its ordinal, 1 for the first); `--start` and `--end` set the range
(the last day by default). `--limit` defaults to 200 lines, at most 1000.

**API**
```http
GET /rds/api/instances/ewdb-0123456789ab/logs?severity=error&contains=deadlock&limit=200
```

**Terraform:** not available. The log is read, not configured.

## Result

Statements slower than `log_min_duration_statement` (1 s by default; set it under **Parameters**,
`-1` turns it off) are logged with their duration. The platform's own statements are logged under
its role, `ews_platform`, once the platform has created that role on the database. When a node writes its log faster than it can be shipped, the skipped
lines are noted on **Activity** (phase `logs`).

## Related

- [Find slow queries](find-slow-queries.md)
- `rds.instances.logs` · `dcloud rds instances logs`
