You need to run the query below then restart PostgreSQL to enable logging persistently. *The parameter with ALTER SYSTEM SET
is set to postgresql.auto.conf
rather than postgresql.conf
:
ALTER SYSTEM SET log_statement = 'all';
And, you need to run either of the queries below then restart PostgreSQL to disable logging persistently:
ALTER SYSTEM RESET log_statement;
Or:
ALTER SYSTEM SET log_statement = 'none';
You can also run the query below then need to restart PostgreSQL to enable logging persistently:
ALTER SYSTEM SET log_min_duration_statement = 0;
And, you can also run either of the queries below then need to restart PostgreSQL to disable logging persistently:
ALTER SYSTEM RESET log_min_duration_statement;
Or:
ALTER SYSTEM SET log_min_duration_statement = -1;
Be careful, these queries below cannot enable or disable logging persistently:
SET SESSION log_statement = 'all'
SET log_statement = 'all'
SET LOCAL log_statement = 'all'
SET SESSION log_min_duration_statement = 0;
SET log_min_duration_statement = 0;
SET LOCAL log_min_duration_statement = 0;
Or:
RESET log_statement;
SET SESSION log_statement = 'none'
SET log_statement = 'none'
SET LOCAL log_statement = 'none'
RESET log_min_duration_statement;
SET SESSION log_min_duration_statement = -1;
SET log_min_duration_statement = -1;
SET LOCAL log_min_duration_statement = -1;
logging_collector = on
– Phenocrystsystemctl restart postgresql
may not actually restart PostgreSQL service you have configured (I don't understand why yet), so changes in the configuration file won't be applied. It is safer to usepg_ctl
(orpg_ctlcluster
on Debian). – Wichernsystemctl reload postgresql
,systemctl restart postgresql
,service postgresql reload
andservice postgresql restart
all render configuration changes effective. – SidemanALTER DATABASE
(as in this answer) – Policyholder