Python logging exceptions with traceback, but without displaying messages twice
Question: If I run the following code:

    
    
    import logging
    logger = logging.getLogger('creator')
    try:
        # some stuff
    except Exception as exception:
        logger.exception(exception)
    

I get the following output on the screen:

    
    
    creator     : ERROR    division by zero
    Traceback (most recent call last):
      File "/graph_creator.py", line 21, in run
        1/0
    ZeroDivisionError: division by zero
    

**Are there ways to get such a output?**

    
    
    creator     : ERROR    ZeroDivisionError: division by zero
    Traceback (most recent call last):
      File "/graph_creator.py", line 21, in run
        1/0
    

Of course, I can get this (but I don't like it):

    
    
    creator     : ERROR    Сaught exception (and etc...)
    Traceback (most recent call last):
      File "/graph_creator.py", line 21, in run
        1/0
    ZeroDivisionError: division by zero
    


Answer: If you called `exception` like this:

    
    
    logger.exception('%s: %s', exception.__class__.__name__, exception)
    

then you could get the exception class name in the initial line.

If you need more precise changes, you can use a custom `Formatter` subclass
which formats things exactly as you like. This would need to override
`format_exception` to change the formatting of the traceback.

