How to find the error log location in PostgreSQL on Windows or Linux environments

In this article, we will see How to find the error log location in PostgreSQL on Windows or Linux environments.

We can get the error log location by running the command log_directory command in psql shell.

Find PostgreSQL error log location in Linux

show log_directory;

How to find the error log location in PostgreSQL on Windows or Linux environments

Then find the log directory location, which is there in PostgreSQL Data directory.

ps -eaf | grep postgres

or

show data_directory;

Find PostgreSQL error log location in Windows

Then navigate to data directory path.

On newer versions, we can find by using below command:

SELECT pg_current_logfile();