def testLoggingException(self):
        log = logging.getLogger('')
        log.setLevel(logging.DEBUG)

        log.addHandler(MongoHandler(self.collection))

        try:
            1/0
        except ZeroDivisionError:
            log.error('test zero division', exc_info=True)

        r = self.collection.find_one({'levelname':'ERROR', 'msg':'test zero division'})
        self.assertTrue(r['exc_info'].startswith('Traceback'))
Logging example with exception
dataset/ETHPy150Open andreisavu/mongodb-log/tests/test_handler.py/TestRootLoggerHandler.testLoggingException