How do I can format exception stacktraces in Python logging?
The logs I am creating in Python are intended to be temporarily stored as files which will, in turn, be processed into a log database. They take a pipe-delineated format to dictate how the logs will be processed, but logging.exception() is breaking my standard by adding one too many fields and way too many newlines. import logging logging.basicConfig(filename='output.txt', format='%(asctime)s|%(levelname)s|%(message)s|', datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.DEBUG) logging.info('Sample message') try: x = 1 / 0 except ZeroDivisionError as e: logging.exception('ZeroDivisionError: {0}'