Setting up Log Retention in Magento v2
Knowledgebase Article
}
Knowledgebase Article
Unlike in version 1, Magento version 2 does not allow you to disable the system and exception logs.
After operating for some time, those could easily get a few GB, which could be a serious issue, especially if you are on a plan with limited disk space.
This article will show you how to setup a cPanel cron job, that will be rotating Magento v2 system and exception logs.

The best method to do that would be via a cron job which you can setup in your cPanel.
Example command line:
1) If you want to keep a copy of the logs:
zip -9 /magento-install-dir/var/log/system-exception.log-`date +%d-%m-%Y-%H-%M`.zip /magento-install-dir/var/log/system.log /magento-install-dir/var/log/exception.log
Replace magento-install-dir with the actual path to your Magento installation directory.
I can recommend running the above on the 1st and 15th of each month:

Compressing the logs can save you more than 90% of the file size!
2) If you do not need a copy of the logs, you can create a cron job with the following command:
> /magento-install-dir/var/log/system.log && > /magento-install-dir/var/log/exception.log
Replace magento-install-dir with the actual path to your Magento installation directory.

That's how you rotate logs in Magento v2.
Should you need any further assistance, please do not hesitate to contact us.
Powered by WHMCompleteSolution