How to get previous log file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get previous log file

Andrus Moor
Hi!

select pg_read_file(pg_current_logfile())

retrieves today log file.
Log files are in log directory:

/var/lib/postgresql/12/main/log# ls
...
postgresql-2020-06-08_000000.log  postgresql-2020-06-18_000000.log  postgresql-2020-06-28_000000.log
postgresql-2020-06-09_000000.log  postgresql-2020-06-19_000000.log

How get yesterday log file from remote client application using postgresql query ?
Using Postgres 12 in Debian.

Andrus.



Reply | Threaded
Open this post in threaded view
|

Re: How to get previous log file

Adrian Klaver-4
On 6/28/20 2:42 AM, Andrus wrote:

> Hi!
>
> select pg_read_file(pg_current_logfile())
> retrieves today log file.
> Log files are in log directory:
>
> /var/lib/postgresql/12/main/log# ls
> ...
> postgresql-2020-06-08_000000.logĀ  postgresql-2020-06-18_000000.log  
> postgresql-2020-06-28_000000.log
> postgresql-2020-06-09_000000.logĀ  postgresql-2020-06-19_000000.log
>
> How get yesterday log file from remote client application using
> postgresql query ?
> Using Postgres 12 in Debian.

You where half way there:

https://www.postgresql.org/docs/12/functions-admin.html

pg_ls_dir() -- To get file names.

pg_read_file() -- Using file name from above.

>
> Andrus.
>
>
>


--
Adrian Klaver
[hidden email]