A system function for showing the locations of log file(s) currently in use

pg_current_logfile() is a system function which will return the path(s) of the log file(s) currently in use.

pg_current_logfile() was added in PostgreSQL 10.


pg_current_logfile(), when called without a parameter, returns in the following order of priority one of:

  • the logfile path where current stderr log output is being directed
  • the logfile path where current csvlog log output is being directed
  • NULL

To return the logfile path of one of the two log types, provide either 'stderr' or 'csvlog' as the function parameter value. See below for examples.

pg_current_logfile() can only be executed by a superuser or a user granted execution permissions on the function, e.g. with:

GRANT EXECUTE ON FUNCTION pg_catalog.pg_current_logfile() TO someuser;
GRANT EXECUTE ON FUNCTION pg_catalog.pg_current_logfile(text) TO someuser;


pg_current_logfile() is a helper function which reports the contents of the file current_logfiles, located at the top-most level of the data directory.

Change history


postgres=# SHOW log_destination;
(1 row)

postgres=# SELECT * FROM pg_current_logfile();
(1 row)

postgres=# SELECT * FROM pg_current_logfile('csvlog');
(1 row)

postgres=# SELECT * FROM pg_current_logfile('foo');
ERROR:  log format "foo" is not supported
HINT:  The supported log formats are "stderr" and "csvlog".


Logging, System function

See also

log_directory, log_destination, pg_rotate_logfile(), pg_ls_logdir()