Parameter · Reporting and Logging / What to Log
log_statement
Sets the type of statements logged.
- Default:
none - Type: enum
- Values: none · ddl · mod · all
- Applies: Session (superuser)
In plain words
Logs the text of SQL statements as they start, filtered by kind: ddl logs schema changes, mod also logs data changes (INSERT, UPDATE, DELETE …), all logs everything including SELECTs. ddl is a popular, low-volume audit trail.
For DBAs and operators
Classes: ddl = CREATE, ALTER, DROP (and similar schema commands); mod = ddl plus INSERT, UPDATE, DELETE, MERGE, TRUNCATE, COPY FROM, and PREPARE/EXECUTE/EXPLAIN ANALYZE of those; all = every statement. Verified on 18.6: with mod, EXPLAIN ANALYZE INSERT and TRUNCATE were logged, COPY … TO was not.
Logging happens before execution (after parsing), so failed statements are logged too, while statements with syntax errors are not. Statements inside functions (PL/pgSQL) are not logged, only the outer call: for full auditing use the pgaudit extension.
With mod or all the log contains data values, including passwords in CREATE/ALTER ROLE … PASSWORD (also with ddl!). all on a busy system generates huge volume and adds latency; prefer sampling or log_min_duration_statement.
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_duration_statement log_duration log_parameter_max_length log_min_error_statement