I have a very simple requirement - PostgreSQL log directory should have fixed max size, e.g. max 10 GB for all PostgreSQL logs.
It can be achieved by creating fixed-size logs and using log rotation (e.g. rotate 10 log files, 1 GB per log file).
I tried to set this up using PostgreSQL logging configuration, but I didn't manage to achieve that. The problem is that "log_truncate_on_rotation" does not works for size-based rotation, only for time-based rotation.
So, my question is - can it be achieved using only PostgreSQL configuration or I have to use something else? If not, why PostgreSQL does not have that feature?
I have few options:
- set max file size to 1 GB using "log_rotation_size" property and then set CRON job which will remove oldest files if file count is above 10
- use logrotate utility, but I have to execute it more often than once per day