title: How to use python logging setLoggerClass?
body: <p>I want to add a custom logger to a python application I am working on. I think that the logging module intends to support this kind of customization but I don't really see how it works with the typical way of using the logging module. Normally, you would create a logger object in a module like,</p>
  
  <pre><code>import logging
  logger = logging.getLogger(__name__)
  </code></pre>
  
  <p>However, somewhere in the application, probably the entry-point, I will have to tell the logging module to use my logger class,</p>
  
  <pre><code>logging.setLoggerClass(MyLogger)
  </code></pre>
  
  <p>However, this is often going to be called after modules have been imported and the logger objects are already allocated. I can think of a couple of ways to work around this problem (using a manager class to register logger allocations or calling getLogger() for each log record -- yuk), but this does not feel right and I wanted to know what the right way of doing this is.</p>