Add logging for database exception