PostgreSQL – Log Queries for a Single Database

postgresql

I'm using PostgreSQL (8.3) with multiple databases… I'm wondering if there is some way to log the queries made only in one of the databases (not all of them).

Or to have one logfile per database…

I know I can use log_line_prefix = "%d" to log the name of the database, and then filter, but that is not the issue.

Should I maybe use a log_analyzer to get around this ? Do you have any recommendations ?

thanks

Best Answer

Yes, this is possible, you can set the configuration parameter log_statement per database:

ALTER DATABASE your_database_name
SET log_statement = 'all';