2

I have been searching in internet for this question "how Magento 2 generate log files and make archive files when the day passes is there an cron or configuration in admin area so I can change it for example archive log files monthly ?

thank you in advance,

3

Magento doesn't rotate logs like you seem to be implying. However, you've likely seen logs get rotated on some servers in locations like /var/log/ where those are rotated by the OS itself. On many Linux servers you'll find a folder called /etc/logrotate.d/ that contains definitions of what files/logs you'd like to rotate. Here's an example one I use to rotate logs for Magento.

File: /etc/logrotate.d/magento

/path/to/magento/var/log/*.log {
    su www-data www-data
    create 640 www-data www-data
    daily
    compress
    missingok
    notifempty
    rotate 50
}

This runs logrotate each night, compressing and renaming log files to only keep single day increments of the logs up to 50 days. The username www-data should be substituted for whichever user your webserver is running as.

Some more info on using logrotate:

  • Thanks @Rhys I was confused :) – lazy_coder Sep 5 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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