Write errors to logfile