You can either untar the pgFouine tarball or install the RPM package.
Edit your postgresql.conf file (usually located in /var/lib/pgsql/data/) and set the following configuration directives:
syslog = 2 log_min_duration_statement = n log_duration = false log_statement = false
syslog = 2 log_min_duration_statement = n log_duration = true log_statement = false
Then edit your /etc/syslog.conf to set up a PostgreSQL facility:
local0.* -/var/log/pgsql
You should also ignore PostgreSQL facility for the default log file otherwise you will log the queries twice:
*.info;mail.none;authpriv.none;cron.none;local0.none /var/log/messages
Restart syslogd and PostgreSQL.
Edit your postgresql.conf file (usually located in /var/lib/pgsql/data/) and set the following configuration directives:
log_destination = 'syslog' redirect_stderr = off silent_mode = on
log_min_duration_statement = n log_duration = off log_statement = 'none'
Then edit your /etc/syslog.conf to set up a PostgreSQL facility:
local0.* -/var/log/pgsql
You should also ignore PostgreSQL facility for the default log file otherwise you will log the queries twice:
*.info;mail.none;authpriv.none;cron.none;local0.none /var/log/messages
Restart syslogd and PostgreSQL.
You can filter your log file on database and user using the -database and -user options. To do so, you need to configure the following log_line_prefix:
log_line_prefix = 'user=%u,db=%d'
Using the following configuration, you can log to stderr instead of syslog. This is not recommended as we cannot guarantee the consistency of statements if they are multilines.
log_destination = 'stderr' redirect_stderr = on log_line_prefix = '%t [%p]: [%l-1] '
pgFouine is an easy to use command line tool. The following command generates an HTML report with all default options:
$ pgfouine.php -file your/log/file.log > your-report.html
The following command line displays a text report with only 10 queries in each list to the standard output:
$ pgfouine.php -file your/log/file.log -top 10 -format text
You can find more examples on the Sample reports page.
By using pgfouine.php -help, you can display the usage information.