Make exception logging failures more robust