Writing errors out to a log file