I'm using an ORM in my app and would like to see all statements sent to Postgres so that I can figure out exactly what the ORM is doing. In the Postgres config file I added log_statement = 'all' to get logging of statements to work, but it puts them in the same log file as all the other things like CET ERROR, CET DETAIL, etc. Is it possible to get a separate log file showing only the statements that Postgres receives?

Even better is it possible to exclude statements sent to Postgres from command like psql, so that I can see exactly what my app is sending to the DB?

Also I'm not sure what exactly is being sent to Postgres, because sometimes in the log file statements appear prefixed with CET STATEMENT: and other times with CET LOG: statement:. What's the difference between these? Sometimes they appear one after another with the same SQL statement so I'm not sure if that means it was run twice or just once.

  • 1
    If you specify an application name when you connect, you can add that application name to the log entry. – a_horse_with_no_name Dec 21 '14 at 22:09
  • Yep, see log_line_prefix in postgresql.conf – Craig Ringer Dec 22 '14 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.