Skip to content

Instantly share code, notes, and snippets.

@carltondickson
Last active August 18, 2020 07:42
Embed
What would you like to do?
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