Added more statements to write to log file to avoid cases where exceptions
are not written to a log file for issue #27