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.
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.
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.
When you configure log rotation, you may want to consider the following factors.
The disk space allocated to your site is important in determining the threshold that you set for your log files. If your site has limited disk space, you need to set a lower threshold.
If your server runs out of disk space, system performance drops, and you lose fresh log data.
Important: If your server runs out of disk space and a log rotate is scheduled to run, you will lose important log data.
On high-traffic sites, log files grow quickly. Review your site's traffic level and the expected log file size when setting your log threshold.
Logs can be rotated four times daily, once a day or weekly, depending on the rate at which log files expand. In general, high-traffic sites require more frequent rotation than low-traffic sites.