Running PostgresSQL 11.4 on Windows 10
I made a DB cluster in C:\Users\WindowsUser\AppData\Roaming\postgresql\Db_1
I registered that cluster to start on as a windows service on startup:
pg_ctl register -D C:\Users\WindowsUser\AppData\Roaming\postgresql\Db_1 -N PostgreSQLdb1 -U WindowsUser -P WindowsPassword -S a
And the Where to log In C:\Users\WindowsUser\AppData\Roaming\postgresql\Db_1\postgresql.conf
I changed the log parameter to a absolute location.:
# - Where to Log -
log_destination = 'stderr' # Valid values are combinations of
# stderr, csvlog, syslog, and eventlog,
# depending on platform. csvlog
# requires logging_collector to be on.
# This is used when logging to stderr:
logging_collector = on # Enable capturing of stderr and csvlog
# into log files. Required to be on for
# csvlogs.
# (change requires restart)
# These are only used if logging_collector is on:
log_directory = 'C:\Users\WindowsUser\AppData\Roaming\postgresql\Db_1\log'
# directory where log files are written,
# can be absolute or relative to PGDATA
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
# can include strftime() escapes
However, the cluster database does not write anything to log. The main PG database is located in a totally different directory, and that database does write to its log file.
Both databases works just fine, except the log part.
I have have even restarted my PC, but it still does not write to log.
pg_ctl start -D :\Users\WindowsUser\AppData\Roaming\postgresql\Db_:\Users\WindowsUser\AppData\Roaming\postgresql\Db_1
(after stopping the service). That should show you potential problems. Perhaps the permissions are wrong?pg_ctl: directory ":/Users/WindowsUser/AppData/Roaming/postgresql/Db_:/Users/WindowsUser/AppData/Roaming/postgresql/Db_1" does not exist
. However this does work if a specify a specific log file:pg_ctl start -D "C:\Users\WindowsUser\AppData\Ro" -l "C:\Users\WindowsUser\AppData\Ro\log\postgresql-2019-10-14.log"
WindowsUser
) can write into that directory? Unrelated, but I prefer a relative directory:log_directory = 'log'
pg_ctl start -D C:\Users\WindowsUser\AppData\Roaming\postgresql\Db_1
. Hmm. Your question has aRoaming
in there, your comment doesn't. What's going on there? Try to changelog_directory
inpostgresql.conf
. If that causes a log file to be written, then it must be some kind of permission problem.pg_ctl start -D "C:\Users\WindowsUser\AppData\Roaming\postgresql\Db_1" -l "C:\Users\WindowsUser\AppData\Roaming\postgresql\Db_1\log\db1_logfile.log"
. I also tried withlog_directory = 'log'
, but when nothing happened, I tried with the absolute dir-path instead. The userWindowsUser
is an admin, so it should have write privileges. However, I added my "answer" below with the event-log alternative.