Friday, 18 May 2018

How to log all the queries in PostgreSQL


The logging settings for PostgreSQL are contained in the postgresql.conf file in the data folder. (It is always a good idea to make a backup of the postgresql.conf file before you make any changes to it.)

Open the postgresql.conf file with a text editor. The logging options are after the following lines:

#------------------------------------------------------------------------------
# ERROR REPORTING AND LOGGING
#------------------------------------------------------------------------------

Change:
#log_min_duration_statement = -1
to:
log_min_duration_statement = 0
and change
#log_statement = 'none'
to:
log_statement = 'all'

Make sure that you remove the # before the changed lines.

Save the amended postgresql.conf file and restart the PostgreSQL service. Alternatively you can reload the postgresql.com file while the server is running with pg_ctl reload.


No comments:

Post a Comment