DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Reporting and Logging / What to Log

log_disconnections

Logs end of a session, including duration.

  • Default: off
  • Type: bool
  • Applies: New connections (superuser)

In plain words

Writes one line when a session ends, saying how long it lasted and who it was. Together with connection logging, this shows connection churn and very short sessions that waste resources.

For DBAs and operators

Real line (18.6):

LOG: disconnection: session time: 0:00:01.512 user=postgres database=postgres host=[local]

For TCP connections the port is added: host=127.0.0.1 port=47888. The line is written by the backend itself at exit, so sessions that end with a crash or SIGKILL do not produce it (look for "terminated by signal" from the postmaster instead).

Use it to measure session length distribution: many sessions of a few milliseconds mean the application connects per request and should use a pooler (pgBouncer) or a client-side pool. Can only be changed at connection start (superuser-backend context). Pairs naturally with log_connections = setup_durations, which shows what each of those short sessions cost to set up.

How to change it

Applies at connection start; superusers can also pass it as a connection option.

See it in context

Client backend Postmaster Process model

Related parameters

log_connections log_hostname idle_session_timeout

All Reporting and Logging parameters