I have a postgres system with a hot standby server. They use the same config file. I've setup the log rotation to use log_rotation_size and log_rotation_age so that the master server is rotated every 10MB and the standby logs are rotated every day.
My parameters are as follows:
postgres=# select name,setting,unit from pg_settings where name like '%log%';
name | setting | unit
-----------------------------+--------------------------------+------
log_autovacuum_min_duration | -1 | ms
log_checkpoints | on |
log_connections | on |
log_destination | stderr |
log_directory | /apps/postgres/pg_log |
log_disconnections | on |
log_duration | off |
log_error_verbosity | default |
log_executor_stats | off |
log_file_mode | 0600 |
log_filename | postgresql-%Y-%m-%d_%H%M%S.log |
log_hostname | on |
log_line_prefix | %u %h %p |
log_lock_waits | on |
log_min_duration_statement | 10000 | ms
log_min_error_statement | error |
log_min_messages | warning |
log_parser_stats | off |
log_planner_stats | off |
log_rotation_age | 1440 | min
log_rotation_size | 10240 | kB
log_statement | ddl |
log_statement_stats | off |
log_temp_files | -1 | kB
log_timezone | Australia/NSW |
log_truncate_on_rotation | off |
logging_collector | on |
syslog_facility | local0 |
syslog_ident | postgres |
My problem is that the logfiles in the production database aren't being rotated at all, while the standby logs are being rotated as expected every day. This is a high availability application so I'm keeping it running at present by copying the logfile to a new file then echoing "" to the current logfile.
Is there anyway I can fix this problem without an outage to the system?
Best Answer
Try the following log parameters. After modify them, remember to reload the configuration file (
$PGDATA/postgresql.conf
).