Skip to content

Instantly share code, notes, and snippets.

@arkan
Forked from ericallam/gist:1019446
Created November 25, 2015 14:59
Show Gist options
  • Save arkan/d3c341b3012879e2c84c to your computer and use it in GitHub Desktop.
Save arkan/d3c341b3012879e2c84c to your computer and use it in GitHub Desktop.
How to log all queries for a PostgreSQL homebrew install on OS X

Open the postgresql.conf config file:

$> mate /usr/local/var/postgres/postgresql.conf

Uncomment the line with 'log_destination' and set it to 'syslog'

log_destination = 'syslog'

Open the syslog config:

$> mate /etc/syslog.conf

And add this line:

local0.*    /var/log/postgresql

Then just restart syslog and postgresql

$> ps aux | grep syslog
$> sudo kill -2 PID

$> launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
$> launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist

Now you can tail the log file and see the queries that rails runs:

$> tail -f /var/log/postgresql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment