I found myself in the need to check a portion of the SQL statements on my PostgreSQL servers. The process is easy and quick but you have to be sure to disable this feature as it writes directly on the PostgreSQL log and if you leave this enabled you might get your hard drive full.
First off locate your
$ find / -name postgresql.conf
Then open it with nano and activate the log_statement flag with the all option. In my case, the file was located under
$ sudo nano /etc/postgresql/10/main/postgresql.conf log_statement 'all'
Save the file and restart the postgresql server:
$ sudo service postgresql restart
Finally, if you want to see the log being written down on your console simply pass the entry of the file to the tail command like this:
$ tail -f /var/log/postgresql/postgresql-10-main.log
You are good to go. You will now be able to watch read the full history of statements executed on your PostgreSQL server.
Remember to undo this to avoid your log file to be full out of the history.