Added automatic deletion of old error log files

Closes #1394