PostgreSQL pg_current_logfile() Function

The PostgreSQL pg_current_logfile() function returns the currently used log file path.

pg_current_logfile() Syntax

Here is the syntax of the PostgreSQL pg_current_logfile() function:

pg_current_logfile([format text]) -> text

Parameters

format

Optional. The format of the date, available values: stderr and csvlog.

Return value

The PostgreSQL pg_current_logfile() function returns the pathname of the log file currently in use by the logging collector.

The pg_current_logfile() function without parameters returns a path to one of the logs in the order of stderr and csvlog.

pg_current_logfile() Examples

To get the path to the current log file, use the following statement with the pg_current_logfile() function:

SELECT pg_current_logfile();
          pg_current_logfile
--------------------------------------
 log/postgresql-2022-07-13_134056.log

Or you can use pg_current_logfile() function with the parameter stderr:

SELECT pg_current_logfile('stderr');
          pg_current_logfile
--------------------------------------
 log/postgresql-2022-07-13_134056.log

Or you can use pg_current_logfile() function with the parameter csvlog:

SELECT pg_current_logfile('csvlog');
 pg_current_logfile
--------------------

Here, the system does not generate logs in csvlog format.