Hands-on Lab·PostgreSQL
PostgreSQL Server Log Configuration
`logging_collector` is off, `pg_current_logfile()` returns NULL, and there is still a log file. Then four settings that turn it into something worth reading.
Monitoring and Operations Guide 40 of 47 Intermediate
- OSUbuntu 26.04 LTS (resolute)
- PostgreSQL18.6-0ubuntu0.26.04.1
- Host2 core / 4 GB, 400,000-row test table
- TimeAbout 18 min
- Reviewed27 August 2026
Written against the versions above. `log_connections` became a **list** in PostgreSQL 18 - `receipt`, `authentication`, `authorization`. `on` is still accepted and means all of them. On 17 and earlier it is a plain boolean.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| db-a01 | 192.168.0.81 | Ubuntu 26.04 LTS | Primary / Source / Replica Set Member 1 | 2 Core | 4 GB | 50 GB |
Before you start
- Shell access as a user who can
sudo -u postgresand read/var/log/postgresql/.
-
Find the log the packaging actually uses
-
Read the prefix
-
Log the slow statements
-
Log who connects, PostgreSQL 18 style
-
Log the lock waits
-
Put it back, and hit a role that will not drop