logging errors in database