Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I enable logging with Postgres.app on OS X?

Running Mountain Lion. Installed PostgreSQL via Postgres.app. Using postgres for Django via PyCharm. I've read multiple SO and blog posts about getting this to work, and logs simply are not being created.

My conf file (data directory) is located here:

$ ~/Library/Application\ Support/Postgres/var/postgresql.conf

My postgresql.conf logging settings look like this:

log_destination = 'stderr'  
logging_collector = on  
log_directory = '~/Library/Logs/Postgres' (I've also tried 'pg_log')

I've tried closing and opening Postgres.app

I've also tried restarting the command line server:

$ /Applications/Postgres.app/Contents/MacOS/bin/pg_ctl restart -D ~/Library/Application\ Support/Postgres/var/

...but this results in the terminal hanging on "LOG: autovacuum launcher started" ... and the logs printing to the console.

This SO post is closely relevant, but I want Postgres.app to write to log files, not print to console.

Any help would be awesome, thanks.

EDIT: In response to vyegorov,

version = PostgreSQL 9.2.2  

silent_mode does not exist in postgresql.conf

like image 489
grokpot Avatar asked Feb 22 '13 04:02

grokpot


People also ask

How do I log into PostgreSQL on Mac?

Using Homebrew This can be done by typing the following command into a terminal: This will start up a postgres server hosted locally on port 5432. The server will be run out of the directory /usr/local/var/postgres . This will connect to the server and access the postgres database.

How do you check if postgres is running on Mac?

psql -c "SELECT 1" -d {dbname} > /dev/null || postgres -D /usr/local/var/postgres >postgres. log 2>&1 & if you want to check and start postgres in one go (handy for automation scripts).


1 Answers

I got it working for me. Here's the settings I'm using:

log_destination = 'stderr'  
logging_collector = on
log_directory = '/tmp/'
log_filename = 'postgresql-%Y-%m-%d.log'
like image 90
phil-monroe Avatar answered Oct 24 '22 17:10

phil-monroe