Question

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,

Was it helpful?

Solution

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:

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top