Parameter · Reporting and Logging / When to Log
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.
- Default:
error - Type: enum
- Values: debug5 · debug4 · debug3 · debug2 · debug1 · info · notice · warning · error · log · fatal · panic
- Applies: Session (superuser)
In plain words
An error message alone ("division by zero") rarely tells you which query failed. With this setting, PostgreSQL adds a STATEMENT: line with the SQL text for every message at or above the chosen severity. The default error does this for all errors.
For DBAs and operators
Uses the server-log order (… warning < error < log < fatal < panic). Because LOG ranks above ERROR, the default also attaches the statement to LOG messages that happen inside a query, such as temporary-file and lock-wait reports:
The STATEMENT line is only added if the message itself is logged (log_min_messages), and only when a statement is running (not for background processes). panic effectively turns the feature off. Lowering it to warning helps find which statements trigger warnings.
The statement text includes literal values, so failed ALTER ROLE … PASSWORD '…' or statements with personal data can appear in the log. For bind parameters, see log_parameter_max_length_on_error. Some sites set this to panic for compliance and rely on error codes instead.
How to change it
A superuser (or a role granted SET) can change it per session with SET.
See it in context
Related parameters
log_min_messages log_parameter_max_length_on_error log_statement log_error_verbosity