How to enable logging of all SQL executed by PostgreSQL 8.3?
Edited (more info) I changed these lines :
log_directory = 'pg_log' log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' log_statement = 'all'
And restart PostgreSQL service... but no log was created... I'm using Windows Server 2003.
Any ideas?
In your data/postgresql.conf
file, change the log_statement
setting to 'all'
.
Edit
Looking at your new information, I'd say there may be a few other settings to verify:
log_destination
variablelogging_collector
log_directory
directory already exists inside of the data
directory, and that the postgres user can write to it.Edit your /etc/postgresql/9.3/main/postgresql.conf
, and change the lines as follows.
Note: If you didn't find the postgresql.conf
file, then just type $locate postgresql.conf
in a terminal
#log_directory = 'pg_log'
to log_directory = 'pg_log'
#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
to log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
#log_statement = 'none'
to log_statement = 'all'
#logging_collector = off
to logging_collector = on
Optional: SELECT set_config('log_statement', 'all', true);
sudo /etc/init.d/postgresql restart
or sudo service postgresql restart
Fire query in postgresql select 2+2
Find current log in /var/lib/pgsql/9.2/data/pg_log/
The log files tend to grow a lot over a time, and might kill your machine. For your safety, write a bash script that'll delete logs and restart postgresql server.
Thanks @paul , @Jarret Hardie , @Zoltán , @Rix Beck , @Latif Premani
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With