Parameter · Reporting and Logging / Where to Log
log_rotation_age
Sets the amount of time to wait before forcing log file rotation. 0 disables time-based creation of new log files.
- Default:
1d - Type: integer (min)
- Range: 0 … 35791394min
- Applies: Reload
In plain words
How long the logging collector keeps writing to one file before it starts a new one. With the default of one day you get one file per day (or one per weekday name if log_filename repeats).
For DBAs and operators
Rotation happens when the time reaches the next multiple of log_rotation_age (counted in the log time zone, so 1d rotates at midnight of log_timezone, 1h on the hour). The new file name comes from log_filename evaluated at that moment; a time-based rotation is also the only kind that honours log_truncate_on_rotation.
Unit is minutes when no unit is given. 0 turns time-based rotation off: files then change only on log_rotation_size, on pg_rotate_logfile(), on a reload that changes log_directory or log_filename, or on restart. Rotation does not print a log line, but $PGDATA/current_logfiles and pg_current_logfile() change.
Typical setups: 1d with a dated or weekday name; 1h with postgresql-%H.log for a 24-hour ring on very busy systems. Requires logging_collector.
How to change it
Change in postgresql.conf or ALTER SYSTEM, then run SELECT pg_reload_conf().
See it in context
Related parameters
log_rotation_size log_filename log_truncate_on_rotation logging_collector