I was trying to troubleshoot a problem on my site and went to look at the system.log file and it was over 1GB.

The exception.log wasn't as big but it got me thinking:

How do you limit the size of the logging files for Magento?

  • i think through cron job you can clear log periodically.there will be settings in the admin. Dec 30, 2015 at 12:20

3 Answers 3



Follow this i think it will help you to solve your issue :-

cd /etc/logrotate.d/
vim magento-logrotate.conf

now add the following to the magento-logrotate.conf file:

/path/to/magento/var/log/*log {
rotate 7

execute your configuration now:

logrotate -f /etc/logrotate.d/magento-logrotate.conf
  • I really like this approach, will try it out and accept after a few days provided it works (it should) or that someone doesnt come up with a better answer.
    – SR_Magento
    Dec 30, 2015 at 14:31
  • Do a cronjob required to run it daily? @Manish Kumar
    – MagePsycho
    May 13, 2019 at 13:11

The most interesting is: what is in your log files?

Generally, the log files contain notifications, warnings and errors. When I have finished building a Magento webshop or a new module, one of my personal requirements is to have nothing appear in the logs when running/using this shop or module. If something would appear, then something should be improved (notices) or is terribly wrong (errors).

To answer your question of how to limit the size of system.log and exception.log files: fix the problems that are described in those files. These files aren't there for nothing.

B.t.w. logrotate (suggested by Manish Kumar) is a great thing too ;)


add new line below to the

$file = empty($file) ? 'system.log' : $file;
$file = date('Ymd').$file;

enter image description here

  • very stupid idea...
    – MagenX
    Dec 30, 2015 at 12:46
  • I can't find this "stupid". It's a hack, but ho-hum.
    – Anse
    Aug 31, 2017 at 12:28
  • I agree this is a stupid idea, unless you would add to your answer how to do this WITHOUT EDITING CORE FILES and you should add a method to clean up "old" log files (for instance with a Bash script that deletes files with a date prefix of X days old...
    – 7ochem
    Dec 18, 2017 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.