How to log PostgreSQL queries?

Created:

2016-11-16 12:54:29 UTC

Modified:

2017-08-08 13:32:42 UTC

0

Was this article helpful?


Have more questions?

Submit a request

How to log PostgreSQL queries?

Applicable to:

  • Plesk 12.0 for Linux

Question

How to increase PostgreSQL log level to see all queries?

Resolution

  1. Open PostgreSQL config file /var/lib/pgsql/data/postgresql.conf .

  2. Add the following values as specified below:

    log_line_prefix = '[%p] [%c] [%m] [%x]: '
    log_statement = 'all'
  3. Reload PostgreSQL:

    bash-4.1$ su postgres
    bash-4.1$ /usr/bin/pg_ctl -D /var/lib/pgsql/data/ reload
    server signaled
  4. PostgreSQL logs will be available in /var/lib/pgsql/data/pg_log/ directory.

Have more questions? Submit a request
Please sign in to leave a comment.