# log_disconnections

> log_disconnections is the PostgreSQL setting that controls whether PostgreSQL logs end of a session, including duration.
---

> [!NOTE]
> **Fact — official short description:** “Logs end of a session, including duration.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `bool` | Upstream pg_settings type |
| Context | `superuser-backend` | Fixed when a superuser backend starts |
| Unit | — | Raw unit |
| Range | — | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Reporting and Logging / What to Log | Upstream classification |
| Latest boot value | `off` | off |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG9.0 (research boundary) |
| Present in | PG9.0–19 Beta 3 |
| Removed in | No |
| Introduction commit | Not asserted: predates the PG9.0 research boundary |
| Commit date | — |
| Discussion | — |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG9.0–19 Beta 3 | `off` | — | off |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

log_disconnections logs end of a session, including duration. The record is emitted at session end and includes session duration, pairing naturally with connection-start identity but not proving that every abrupt failure reached the logger.

log_disconnections has SUPERUSER_BACKEND context: configuration changes apply when a new backend session starts and require superuser-level authority; established sessions keep their startup value.

It changes emitted diagnostic data rather than query semantics, but volume, sensitive content, log_line_prefix, destinations, collector throughput, and retention determine operational cost and usefulness.

## Tuning advice {#tuning-advice}

> [!TIP]
> **Advice.** These are workload-specific starting points and must be validated with measurements.

| Workload | Guidance |
| --- | --- |
| OLTP | Tune log_disconnections against an explicit observability question and a measured log-volume budget. Prefer selective thresholds, sampling, or role-level overrides over indiscriminate capture. |
| OLAP | Analytical jobs can justify richer log_disconnections telemetry, but account for long statements, large bind values, and bursty completion patterns in the log pipeline. |
| Small nodes | Keep log_disconnections useful but bounded: verify disk, collector, retention, and redaction capacity before increasing detail or frequency. |
{.full-width}

## Pigsty {#pigsty}

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

| Template | Effective value | Versus upstream boot | Source expression |
| --- | --- | --- | --- |
| OLTP | Unmodified | — | — |
| OLAP | Unmodified | — | — |
| CRIT | `on` | different | `'on'` |
| TINY | Unmodified | — | — |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG9.0–19 Beta 3 unmodified; OLAP: PG9.0–19 Beta 3 unmodified; CRIT: PG9.0–19 Beta 3 = on (dcs); TINY: PG9.0–19 Beta 3 unmodified. Advice, pending human review — Editorial inference: CRIT records session endings and durations to complete its connection audit trail, accepting additional volume only in that profile.

## Common pitfalls {#common-pitfalls}

- Expecting existing sessions to inherit a new log_disconnections value even though it is fixed when each backend starts.
- Enabling richer logging without budgeting collector throughput, storage, retention, and downstream query cost.
- Writing SQL text, bind values, identities, or host data without a redaction and access-control policy.
- Changing log_disconnections globally without a rollback plan and a client or operational compatibility test.

## Related parameters {#related-parameters}

[`log_statement`](/parameters/log-statement/) · [`log_duration`](/parameters/log-duration/) · [`log_connections`](/parameters/log-connections/) · [`log_parameter_max_length`](/parameters/log-parameter-max-length/) · [`log_parameter_max_length_on_error`](/parameters/log-parameter-max-length-on-error/)

## References {#references}

- [PostgreSQL 19 Beta 3 — log_disconnections](https://www.postgresql.org/docs/19/runtime-config-logging.html#GUC-LOG-DISCONNECTIONS)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
