This article demonstrates how to add directories to your log rotation plan. For example, you may have a directory where you put custom logs for your applications or perhaps you want to rotate Magento (shopping platform) logs. You can use this method.
You have to decide your retention and rotation policy. It’s very simple:
1. How often do you want to rotate your log files? In other works, how often do you want to take the log files in a given directory, zip and rename them and then create new ’empty’ log files in their place? Your options are Daily, Weekly, Monthly and Yearly.
2. What is your retention policy? In other words, how many zipped files of each log file do you want to keep? You can choose any number here.
The following example rotates log files in “/var/log/myApp” every week and keeps 4 zipped log files (4 weeks retention).
/var/log/myApp/* { rotate 4 weekly create compress missingok notifempty }
Put the above into a file called “myapp” and place that file into the “/etc/logrotate.d” directory and you’re done. You can call your log rotation file anything you like.