title: How do you add a handler to a Python Logger object globally?
body: <p>I want to create a logger for my project which has a custom handler that works across all submodules and which logs uncaught exceptions.  Below is my proof-of-concept; note that I am using a file handler as a stand-in for what will eventually be my custom handler.</p>
  
  <p>main.py:</p>
  
  <pre><code>import logging
  import sys
  from module import divide
  
  logger = logging.getLogger(__name__)
  logger.setLevel(logging.INFO)
  
  fh = logging.FileHandler("test.log")
  fh.setLevel(logging.INFO)
  logger.addHandler(fh)
  
  def uncaught_error(exc_type, exc_value, exc_traceback):
      logger.error("Uncaught Exception", exc_info = (exc_type, exc_value, exc_traceback))
      sys.__excepthook__(exc_type, exc_value, exc_traceback)
      return
  
  sys.excepthook = uncaught_error
  
  if __name__ == '__main__':
      logger.info("first division problem")
      print(divide(5,2))
      logger.info("second division problem")
      print(divide(10,0))
      logger.info("end")
  </code></pre>
  
  <p>module.py:</p>
  
  <pre><code>import logging
  
  logger = logging.getLogger(__name__)
  
  def divide(a, b):
      logger.info("dividing " + str(a) + " by " + str(b))
      return a/b
  </code></pre>
  
  <p>After I run main.py, here is the output of test.log:</p>
  
  <pre><code>first division problem
  second division problem
  Uncaught Exception
  Traceback (most recent call last):
    File "main.py", line 23, in &lt;module&gt;
      print(divide(10,0))
    File "/some/path/logging_test/module.py", line 7, in divide
      return a/b
  ZeroDivisionError: division by zero
  </code></pre>
  
  <p>The uncaught exception in module.py was logged beautifully, but the line</p>
  
  <pre><code>logger.info("dividing " + str(a) + " by " + str(b))
  </code></pre>
  
  <p>apparently did nothing (there was no console output either).  What is the mistake?</p>