log exception properly