CRM-13402 error logging improvements incl fix to infinite loop when sql server gone away