store error messages in the script log file. Fix #1281