Skip to content

Instantly share code, notes, and snippets.

@carltondickson
Last active August 18, 2020 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carltondickson/cdb13caaa86a3b1ce3fc6b434f0c0dc8 to your computer and use it in GitHub Desktop.
Save carltondickson/cdb13caaa86a3b1ce3fc6b434f0c0dc8 to your computer and use it in GitHub Desktop.
Postgres - Enable/Disable query logging

Enable query logging

  • Check version, determine which config file to edit

  • SELECT version();

  • PostgreSQL 12.3 (Ubuntu 12.3-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0, 64-bit

  • sudo nano /etc/postgresql/12/main/postgresql.conf

  • Find REPORTING AND LOGGING section and change following settings

  • log_statement = 'all'

  • Reload configuration from command line SELECT pg_reload_conf();

  • Tail log file tail -f /var/log/postgresql/postgresql-12-main.log

Disable query logging

  • Comment out log_statement line
  • SELECT pg_reload_conf();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment