PostgreSQL – How to Modify log_rotation_size Parameter

The log_rotation_size parameter determines the size at which PostgreSQL’s log files (usually the log file generated by the pg_log system) will be rotated or switched to a new file. Rotating log files helps postgresql database engine to manage the log file size and prevent them from growing too large, which can be particularly useful for managing disk space.

The log_rotation_size parameter is defined in PostgreSQL’s configuration file, which is typically named postgresql.conf. It is measured in kilobytes (KB) by default, but you can specify it in other units such as megabytes (MB) or gigabytes (GB) by using appropriate suffixes. The default value for log_rotation_size is 10 megabytes (10MB).

Here’s an example of how you can set the log_rotation_size parameter in your postgresql.conf file:

log_rotation_size = 10MB

This setting would cause log files to be rotated once they reach 10 megabytes in size.

You should consider your specific system’s disk space and log retention needs when adjusting the log_rotation_size parameter. You can set it to a larger value if you have ample disk space, or a smaller value if you want more frequent log rotations to keep log files smaller.

After making changes to the log_rotation_size parameter in your postgresql.conf file, you will need to restart PostgreSQL for the changes to take effect. Here is the command to restart postgresql:

sudo service postgresql restart

Monitor your log files and adjust this setting as needed to ensure effective log management for your PostgreSQL instance.

Similar Posts