Don't use the logger from a trap context. Fixes #801.