PostgreSQL Logs – How to Log Startup Errors on Windows

logspostgresql

I have been experimenting with Postgres configuration parameters and noticed that when I use settings that prevent Postgres from starting nothing shows up in the pg_log directory logs. I have

log_destination = 'stderr'
logging_collector = on
log_directory = 'pg_log'

Is there a way to cause Postgres to log startup errors to pg_log on Windows 7 and Postgres 9.3?

Best Answer

There's a chicken-and-egg problem there.

PostgreSQL reads postgresql.conf to decide where to log, and how.

So it cannot really log errors in postgresql.conf to the PostgreSQL logs, unless it uses some kind of fallback/default log.

Instead, it uses the Windows Event Log, which is what Windows applications are supposed to do anyway. (You can have PostgreSQL write all logs to the Windows Event Log if you prefer, by changing its logging configuration).

So you should look in the windows event log - see the Event Viewer - for startup issues with PostgreSQL.