Having built Postgres 11.1 on my FreeBSD 11.2 machine, where might I find the logs output from Postgres.

Specifically, when attempting to start Postgres for the first time, I get an error message from pg_ctl telling me to examine the logs for an explanation of the problem.

$ /usr/local/bin/pg_ctl -D /var/db/postgres/data11 -l logfile start
pg_ctl: another server might be running; trying to start server anyway
waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.

When building Postgres, the final output mentions:

NB. FreeBSD's PostgreSQL port logs to syslog by default
  See ~pgsql/data/postgresql.conf for more info

When I look in that file, the only entry on logging is:

log_destination = 'syslog'

➥ How do I query syslog for my Postgres logs?

  • Have you initialized your database with command /usr/local/etc/rc.d/postgresql initdb? Please prepare a log file and show us any errors.
    – taro
    May 19, 2019 at 9:50

2 Answers 2


First of all, you will have to create a dedicated log file for PostgreSQL:

touch /var/log/postgresql.log
chown postgres:wheel /var/log/postgresql.log
chmod 640 /var/log/postgresql.log

After that update /etc/syslog.conf and redirect messages from PostgreSQL to the log file just created by adding entry like this:

local0.*     /var/log/postgresql.log

Don't forget to restart syslogd to apply your changes:

kill -HUP `cat /var/run/syslog.pid`

@taro's answer is the right approach, but unfortunately adding a filter for local0.* /var/log/postgresql.log will redirect all syslog local0-directed messages to /var/log/postgresql.log, including output from other applications and daemons.

The correct answer would be to either add a specific app filter to /etc/syslog.conf or create a postgres-specific syslog directive file in /etc/syslog.d/postgres.conf or /usr/local/etc/syslog.d/postgres.conf (you may need to create the /usr/local/etc/syslog.d directory first).

If going with the first approach, you would add the following line to /etc/syslog.conf:

postgres.*  /var/log/postgresql.log

If going with the second approach (recommended), you would create a new file postgres.conf in one of the syslog.d directories with the following contents:

*.*     /var/log/postgresql.log

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .