0

I have configured the following settings in postgreSQL 13.

logging_collector = on  
log_rotation_size='100MB'
log_truncate_on_rotation = on    
log_filename ='postgresql-%Y-%m-%d.log'

My issue is when the log file size reached 100MB, it will continue to append on it, I think it is because of the log_filename. Is there anyway I can rename the filename when it reached the log_rotation_size? I need to set the log_filename with this format (without the time) so that whenever I restart the service, the log will still be in the same log file.

Do I have to run some script or services on the background so that the program is able to monitor the data/logs folder and rename the file when the log file size reaches the limit?

xxestter
  • 441
  • 7
  • 19

1 Answers1

0

As the documentation says:

However, truncation will occur only when a new file is being opened due to time-based rotation, not during server startup or size-based rotation.

Truncating the log file in your case would mean to lose recent log information, so PostgreSQL won't do it.

I can think of no better way than a cron job that removes the log file when it approaches the limit. Then size based log rotation will create the file again.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263