Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql 9.3 log only insert, delete and update

I want to only log queries that modify tables (INSERT, DELETE, UPDATE) while ignoring all SELECTs and its equivalents.

However, in the documentation, my options are to log ddl, ddl+mod or all in the log_statement line of the postgresql.conf file.

Is there some way to log into files all queries that manipulate data by changing settings of the configuration file or will I have to use some outside script or log to tables?

My current settings on my postgresql.conf, which still logs SELECT queries, are as follow:

log_destination = 'syslog, csvlog'
logging_collector = on
log_min_duration_statement = 0
log_statement = mod
like image 227
Arthur Avatar asked May 27 '26 16:05

Arthur


1 Answers

As a_horse_with_no_name and Craig pointed out, log_statement = mod shouldn't be logging select statements.

My problem was log_min_duration_statement = 0, which was acting as an AND, so to say (log this AND that). I've commented the log_min_duration out and now it is only logging what I actually needed.

like image 82
Arthur Avatar answered May 30 '26 02:05

Arthur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!