pg_log_userqueries is a PostgreSQL module that logs each query executed by a superuser. It records each query in the standard log file. There are also two more optional parameters that allow you to log all queries per database and/or per user. * pg_log_userqueries.log_db: to give a pipe separated list of database to log. * pg_log_userqueries.log_user: to give a pipe separated list of user to log. You can use advanced regular expression in that list. For example: * pg_log_userqueries.log_usr="postgres|admin_.*|.*_adm" will match if the exact username is 'postgres' or it begins by 'admin_' or ending by '_adm'. By default pg_log_userqueries will write queries to PostgreSQL log destination. As superuser can modify this behavior, you can force pg_log_userqueries to log independently into syslog by setting a syslog facility. pg_log_userqueries.syslog_facility='local0' This will enable syslog output by selecting a level of log. It takes the same options than PostgreSQL syslog_facility configuration directive. You can also modify the syslog program ident string with configuration directive: pg_log_userqueries.syslog_ident='pg_log_userqueries' Select syslog program identity name.