smarter logging of exception stack traces