Log queries in Postgres on Mac OS X

Sometimes, it's useful to log queries during development in Postgres. Assuming you installed Postgres using brew install postgresql, here's how you configure logging.

Open /usr/local/var/postgres/postgresql.conf in your favorite editor and add these lines:

logging_collector = on
log_directory = 'pg_log'
log_statement = 'all'

Restart Postgres, and run tail -f /usr/local/var/postgres/pg_log to see queries.

Note that logging may take a few moments to start up.