PostgreSQL Query Logging
Sometimes you want to see the queries that are executing on your PostgreSQL database.
This is mostly useful during development.
I wouldn’t recommend doing this in produciton unless you’re aware of the impacts.
Logging
Enable or disable query logging by running the appropriate statement in psql
or however you’re
connecting the database.
Replace your_db
with the name of your database.
Enable Logging
# ALTER DATABASE your_db SET log_statement = 'all;
Disable Logging
# ALTER DATABASE your_db SET log_statement = 'none';
See The Queries
Your log file may be in a differet location depending on the OS or distribution that you’re running and the version of Postgres that you’re using.
$ sudo tail -f /var/log/postgresql/postgresql-11-main.log
Read other posts