added exception handling in database logging to prevent stalling in event of database error