1

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 example 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?

1
  • 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 '19 at 9:50
0

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`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.