About Logrotate

The Log Manager uses the Logrotate utility to manage the server log files. Depending on the frequency and size of the log files, Logrotate archives the log data. The system then populates the empty log file with fresh log data. This is called log rotation.

Why Logs Need to be Rotated

Log files, on a busy server, grow very quickly. A server that receives 100,000 requests a day could generate an access-log file of 10 to 20 MB in size. Over time, such log files consume a great deal of disk space if they are not compressed and rotated on a regular basis.

How Logrotate Works

Logrotate compresses and rotates logs based on the thresholds configured for size and frequency. You set these thresholds when you configure Logrotate. Thresholds are saved in the configuration file, logrotate.conf, located inside the file system of the site.

When the log file reaches the set thresholds, Logrotate archives it in the same directory. The system then writes new log data to the empty log file.

Note: Before Logrotate is scheduled to run, the system generates Webalizer and Analog log reports.

By default, logs are compressed and placed in an archive file.

For example, if the access-log file for the server has reached the rotate threshold, then it is compressed as an access-log.gz file and fresh logs are written to the access-log file, which is now your current log file.

You can set Logrotate to archive uncompressed files, however.

For example, if the access-log file for the server has reached the rotate threshold, then a new file, access-log.1 is created into which the existing log data is archived, and fresh log data written to the access-log file, which is now your current log file.

Factors to Consider When Configuring Log Rotation

When you configure log rotation, you may want to consider the following factors.