3

Exception.log and System.log under /var/log folder in Magento are over 2gb each.

Is it safe to clean them? If yes, what is the proper way of cleaning such logs?

Really appreciate all suggestions!

Icon
  • 911
  • 1
  • 10
  • 31
  • Possible duplicate of [Clearing Magento Log Data](http://stackoverflow.com/questions/3638361/clearing-magento-log-data) – Sam Malayek Jun 12 '16 at 00:06
  • 1
    Seen that topic, the buit-in admin log data cleaninig option is mostly for the database. Excludes var/log cleaning. It has to be done manually. – Icon Jun 12 '16 at 00:14
  • This is a server administration issue, use your server admin skills to set up Magento's logs to be monitored by logrotate. Or just use your Magento admin skills in the backend and shut off error logging. http://magento.stackexchange.com/questions/6818/maintenance-on-large-logging-files-in-magento and https://gist.github.com/molotovbliss/60830cf505b6231852fe – Fiasco Labs Jun 12 '16 at 00:24
  • Okey, but in general it's safe to simply delete both of these .log files and keep the magento logging as "ON"? I was thinking that if I delete these files I have to recreate exactly new ones manually, or does the system creates new ones automatically? – Icon Jun 12 '16 at 05:04
  • They are autocreated. – Fiasco Labs Jun 15 '16 at 05:39

2 Answers2

2

For the log files in var/log, it is safe to rotate them, zip them, delete them, truncate them, etc...

Best practices would say you should rotate them out on a periodic basis, zip them, and retain for xx days for review /analysis if it's needed.

On Linux based servers, using a program such as logrotate is a common set up for log rotation. The file /etc/logrotate.conf can be appended with log rotation for Magento log files:

/home/*/www/var/log/*log {
rotate 14
daily
compress
}

This would keep 14 days of logs, compressed daily.

  • Could you please confirm that if I delete the exception.log and system.log files they will recreate themselves automatically. or, do I have to recreate these files manually right after deletion ? – Icon Jun 13 '16 at 02:02
  • Yes the files will recreate automatically. – Rob Mangiafico Jun 13 '16 at 11:00
1
System > Configuration > Advanced > System > Log Cleaning

EDIT:

You can disable the creation of these files in System > Configuration in the 'Developer' section (inside the Advanced group). Then go to the 'Log Settings' accordion. There will be an option to disable both system.log and exception.log.

Since you can disable their creation, I don't see why deleting them would cause any problems.

Sam Malayek
  • 3,595
  • 3
  • 30
  • 46
  • 1
    This option does not clean exception and system logs. – Icon Jun 12 '16 at 00:07
  • No, but if the log files are 2GB each and you've never looked at them, not logging anything could be an option for you. I don't endorse not logging anything, but it at least will save a lot of disk space if you never dive into the logs anyway. That being said: The other answer (log rotate) is more of a 'best practice'. – JerkMan May 07 '18 at 15:11