Benefits of log rotation
I think the benefits of log rotation are clear:
- You get easily managed smaller log files instead of one huge log file.
- You don't run out of disk space suddenly if you configure it appropriately according to your capacity limits. (
size
option) - Older log files can be compressed so that log files get even smaller in size, and thus saving more disk space. (
compress
option). - You can rotate the files in a specific way / time. For example, each log file contains only information related to a specific day. This will make the search easier given that you know the date. When you don't know the date, you can just search all files or a subset of them. (
daily
,monthly
, etc). - You automatically get rid of very old files. For example, you can keep 30 files at max. (
rotate 30
). - You can add the extension you like such as rotation date. (
dateext
). - You can execute specific scripts before/after rotation. (
prerotate
,postrotate
).
EDIT: I added more items to the list and included the options when applicable. For more details, man logrotate
can be consulted.