pg_log_userqueries Install ========================== To install pg_log_userqueries, you can untar the pg_log_userqueries tarball anywhere you want. You'll need to compile it. There are two ways to do that: * In the PostgreSQL source code directory, inside the contrib sub-directory Put the pg_log_userqueries source directory inside the contrib subdirectory of PostgreSQL. Do "make", then "make install" * Using pgxs Do "make USE_PGXS=1", then "make USE_PGXS=1 install" Once it's installed, you'll need to configure PostgreSQL to make use of it: * shared_preload_libraries='pg_log_userqueries' There are also optional parameters. To configure them, you first need to add the class of pg_log_userqueries in custom_variable_classes: * custom_variable_classes = 'pg_log_userqueries' Then you'll be able to set the two following parameters: * pg_log_userqueries.log_level: to choose the log level of pg_log_userqueries * pg_log_userqueries.log_label: to give the prefix of the log line for pg_log_userqueries logs. Once the configuration is done, restart PostgreSQL. There are also two more optional parameters that allow you to log all queries per database and or per user. The default is to log only superuser queries. * 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.