title: Python Logging does not work over modules
body: <p>In my main.py file I initialize the logger as follows:</p>
  <pre class="lang-py prettyprint-override"><code># File: main.py
  import logging
  logger = logging.getLogger(__name__)
  
  import submodule
  
  #...
  
  def main():
      logger.debug(f'Test')
  
  if __name__ == '__main__':
      logger.setLevel(logging.DEBUG)
      formatter = logging.Formatter('[%(levelname)s | %(name)s] %(message)s')
  
      # The handler h1 logs only debug and info to stdout
      h1 = logging.StreamHandler(sys.stdout)
      h1.setLevel(logging.DEBUG)
      h1.addFilter(lambda record: record.levelno &lt;= logging.INFO)
      h1.setFormatter(formatter)
  
      # The handler h2 logs only warning, error and exception to stderr
      h2 = logging.StreamHandler()
      h2.setLevel(logging.WARNING)
      h2.setFormatter(formatter)
  
      logger.addHandler(h1)
      logger.addHandler(h2)
  
      main()
  </code></pre>
  <p>When I use the logger in the main script, everything works correctly.
  But when I use it in a submodule like this:</p>
  <pre class="lang-py prettyprint-override"><code># File: submodule.py
  import logging
  logger = logging.getLogger(__name__)
  
  #...
  
  logger.info('Test 1')
  logger.error('Test 2')
  </code></pre>
  <p>I should see the following output (or something like this):</p>
  <pre><code>[DEBUG | __main__] Test
  [INFO | submodule] Test 1
  [ERROR | submodule] Test 2
  </code></pre>
  <p>But I get this output:</p>
  <pre><code>[DEBUG | __main__] Test
  Test 2
  </code></pre>
  <p>To me it looks like the logger in submodules did not use the config of the logger in the main module. How to fix that?</p>