Using Log Rotation
As you have seen throughout this chapter, the collection and use of logs is an important task for your CMS website. Logs can be the prognosticator of things to come, or the historical record of things that have passed.
Logs are useful for a short while. Unless you are required (by business or legal requirements) to maintain years of logs, you should maintain about three to four months of your logs. However, this is just a number based on personal experience. Your business needs will dictate the proper time.
Log rotation entails rolling logs over. In layman's terms, log rotation is essentially closing the log files by compressing them and starting new ones. The Linux operating system provides a terrific means to handle this job for you.
Log rotation is driven by a cron job (timer) that will wake up and read a configuration file. That file contains a set of instructions to tell the logrotate utility what to do with each of the logs.
Additionally, you may be on a web host that supports cPanel, or an equivalent. These applications also provide the capability to set up log rotation.
Setting Up Log Rotation with logrotate
You can perform log rotation manually, and in some cases, set it up in your server control panel.
The WHM Virtual Private Server (VPS) control panel from cPanel.com offers an easy means to set up your rotations. In your WHM control panel, you can access the option for log rotation by choosing Main Service Configuration Apache Configuration Log ...
Get CMS Security Handbook: The Comprehensive Guide for WordPress®, Joomla!®, Drupal™, and Plone® now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.