I was running into an issue with the system.log and some custom log files getting way to large to find anything or even to open them.

Normally we don't run logs on live webshops but in this case it was necessary. This resulted in log files reaching sizes of several hundred Mb.

I'm looking for a solution where, just like Apaches logs the files are split up by day and only retained for X days.

3 Answers 3


I personally prefer to just use logrotate to rotate, gzip and delete the logs.

  • Thanks for the feedback, in your case a simple cronjob would do the trick I guess packing and deleting files each day. To do this from the extension would be overkill. Aug 16, 2013 at 13:42
  • yes, just configure logrotate, put it in a cronjob and it does what you want, but be careful, we just missconfigured it and hat millions of files because the count of them raises exponentially each day :-) Aug 16, 2013 at 15:54
  • I fully recommend using logrotate - this is a devops thing, isn't it? :)
    – philwinkle
    Aug 16, 2013 at 16:42
  • Yes, absolutely, not our problem :D Aug 17, 2013 at 18:24
  • 1
    The irony is that "devops" means, it actually IS our problem ;) Here's an example configuration that archives (compresses) each log file after a week and keeps the last three archived versions for each. Wildcards come in handy for multiple sites and multiple log files: /var/www/*/htdocs/var/log/*.log { \n compress \n weekly \n rotate 3 \n } (\n for line break) Jun 12, 2017 at 12:43

I've created an extension that implements log rotation (in my case daily) and cleans them up after 20 days using a Magento cron job. Both settings you can change from the System > Configuration > System > Log cleaning

You can get it from https://github.com/sandermangel/rklogrotate. Feel free to let me know if you have tips or suggestions.

  • As mentioned in other comments, if you can configure log rotate using cronjobs please do. If not, this extension might be a nice second-best Aug 16, 2013 at 21:26
  • Link doesnt worky anymore. Can you please update?
    – sv3n
    Jul 17, 2017 at 14:17

Put this in /etc/logrotate.d/magento

/var/www/magesite/var/log/*.log {
        size 10M
        rotate 50
        dateformat -%Y-%m-%d-%s

Source: fixes.co.za magento2 logrotate

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.