Added code to log database errors to a .log file