How to do it...

The server log can be in a few different places, so let's list all of them first, so that we can locate the log or decide where we want it to be placed:

If not redirected to syslog, the server log consists of one or more files. You can change the names of these files, so it may not always be the same on every system.

On Debian or Ubuntu systems, the default server log location is /var/log/postgresql. The current server log file is named postgresql-R.r-main.log, where R.r represents the major and minor release numbers of the server, for example, 9.6. From release 10 onwards, there will be just one number. The older log files are numbered as postgresql-10-main.log.1. The higher the final number, the older the file, since they are being rotated by the logrotate utility.

On Red Hat, RHEL, CentOS, and Fedora, the default server log location is a subdirectory of the data directory, that is, /var/lib/pgsql/data/pg_log.

On Windows systems, the messages are sent to the Windows Event Log by default.