Fix exception logging