code: def exception_logging(exctype, value, tb):
      
      write_val = {'exception_type': str(exctype),
                   'message': str(traceback.format_tb(tb, 10))}
      logging.exception(str(write_val))
docs: Log exception by using the root logger.
  
      Use it as `sys.excepthook = exception_logging`.
  
      Parameters
      ----------
      exctype : type
      value : NameError
      tb : traceback