log_min_error_statement
Read PG 18 manual ↗Controls which SQL statements that cause an error condition are recorded in the server log.
- Type
- enum
- Context
- superuser
- Measured default
- error
- Unit
- —
- Metadata snapshot
- 18
- Allowed values
- debug5, debug4, debug3, debug2, debug1, info, notice, warning, error, log, fatal, panic
Definition PG 18 manual
Controls which SQL statements that cause an error condition are recorded in the server log. The current SQL statement is included in the log entry for any message of the specified severity or higher. Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, INFO, NOTICE, WARNING, ERROR, LOG, FATAL, and PANIC. The default is ERROR, which means statements causing errors, log messages, fatal errors, or panics will be logged. To effectively turn off logging of failing statements, set this parameter to PANIC. Only superusers and users with the appropriate SET privilege can change this setting.
Measured default history
| Version interval | Default |
|---|---|
| 9.0 – 19 | error |
Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗
How it works
log_min_error_statement causes all statements generating error at or above this level to be logged. Each level includes all the levels that follow it. The later the level, the fewer messages are sent. It governs whether the SQL statement associated with an error-level message is included; log_min_messages separately decides whether the message itself is emitted.
log_min_error_statement is a SUPERUSER-context setting. Superuser or a role granted the appropriate SET privilege can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.
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.
Operational considerations
Changing log_min_error_statement in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.
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_min_error_statement globally without a rollback plan and a client or operational compatibility test.
Workload guidance
OLAP: Analytical jobs can justify richer log_min_error_statement telemetry, but account for long statements, large bind values, and bursty completion patterns in the log pipeline.
OLTP: Tune log_min_error_statement against an explicit observability question and a measured log-volume budget. Prefer selective thresholds, sampling, or role-level overrides over indiscriminate capture.
SMALL: Keep log_min_error_statement useful but bounded: verify disk, collector, retention, and redaction capacity before increasing detail or frequency.
Version history 1
- PG 14 → 15changed
Related entries
Further reading
Definition snapshot: english-manuals:a5941303d7c9fa7bfd1e97c384b… · English manual source