Re: Log retention query

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Paul Brindusa <paulbrindusa88(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Log retention query
Date: 2025-01-28 13:28:36
Message-ID: f6fb8364619a84f9b535edaaceb568dc2377da0d.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2025-01-28 at 09:57 +0000, Paul Brindusa wrote:
> Good morning everyone,
>
> Before I get on with today's problem, I would like to say how much I appreciate this community and everything that you do for end users.
>
> In today's problem I would like to understand if the following lines in our config handle the log rotation for our clusters?
>
>         log_checkpoints: on
>         logging_collector: on
>         log_truncate_on_rotation: on
>         log_rotation_age: 1d
>         log_rotation_size: 1GB
>         log_error_verbosity: verbose
>
> I have been deleting the logs manually for the last month, since I am confused how the log collector rotates them. 
>
> Am looking to delete logs older than 180 days. What are we doing wrong in the config?

It all depends on how you configured "log_filename".

If the setting is "postgresql-%a.log" or "postgresql-%d.log", PostgreSQL
will recycle the old log files once a week or once a month.

If the setting is the default "postgresql-%Y-%m-%d_%H%M%S.log", the same
log file name will never be reused, and there will be no log rotation.

PostgreSQL doesn't actively delete old log files.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Paul Brindusa 2025-01-28 13:40:42 Re: Log retention query
Previous Message Дмитрий 2025-01-28 13:09:07 Re[2]: FATAL: could not send data to WAL stream: lost synchronization with server: got message type "0", length 892351284