Log rotation for PgBouncer
Simple logrotate
config to rotate logs from PgBouncer running as Docker container. Save it to /etc/logrotate.d/pgbouncer
and test it by running sudo logrotate -d /etc/logrotate.d/pgbouncer
# File: /etc/logrotate.d/pgbouncer # Logrotate configuration for pgbouncer logs # This file is intended to be placed in /etc/logrotate.d/pgbouncer /var/log/pgbouncer/pgbouncer.log { # Rotate logs once per day daily # Keep 7 rotated log files (7 days of history) rotate 7 # Compress rotated log files to save disk space compress # Delay compression until the next rotation cycle # (useful if processes might still be writing to recently rotated files) delaycompress # Don't error out if the log file is missing missingok # Don't rotate if the log file is empty notifempty # Create new log file with specified permissions, owner, and group # Format: create mode owner group create 0644 root root # Copy the log file, then truncate the original to zero size # This allows pgbouncer to continue writing to the same file handle # without needing to restart or send signals to the Docker container copytruncate }