-
Notifications
You must be signed in to change notification settings - Fork 21
How to turn on SQL statement logging in postgres
Christopher Keith edited this page Dec 7, 2022
·
11 revisions
Using knex
- Add
DEBUG=knex:query
to thepackages/server/.env
file - Run
docker compose up -d
to reload the changes - Run
docker compose logs app -f -t
to see the log
Using postgres
- Modify
docker-compose.yml
so that theservices.postgres.environment
array contains the following new entry:- POSTGRESQL_PGAUDIT_LOG=all
- Run
docker compose up -d
to reload Postgres container - Run
docker compose logs postgres -f -t
- Hit the "Browse Grants" tab to verify that the SQL statements are being logged
sudo nano /etc/postgresql/14/main/postgresql.conf
Add:
chris@2018-ck-nuc:~/github/usdr-gost$ sudo service postgresql stop
* Stopping PostgreSQL 14 database server [ OK ]
chris@2018-ck-nuc:~/github/usdr-gost$ sudo service postgresql start
* Starting PostgreSQL 14 database server [ OK ]
chris@2018-ck-nuc:~/github/usdr-gost$
sudo nano /var/log/postgresql/???
Reference: https://stackoverflow.com/questions/722221/how-to-log-postgresql-queries