title: Python Logging - How to inherit root logger level & handler
body: <p>I am a python newbie, trying to implement logging into my code. I have two modules</p>
  
  <blockquote>
    <p>main.py
     submodule.py</p>
  </blockquote>
  
  <p><strong>main.py</strong></p>
  
  <pre><code>import logging
  from logging.handlers import RotatingFileHandler
  import submodule
  
  
  import logging
  from logging.handlers import RotatingFileHandler
  
  logger = logging.getLogger(__name__)
  logger.setLevel(logging.DEBUG)
  
  fh = RotatingFileHandler('master.log', maxBytes=2000000, backupCount=10)
  formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
  fh.setFormatter(formatter)
  logger.addHandler(fh)
  
  logger.debug('DEBUG LEVEL - MAIN MODULE')
  logger.info('INFO LEVEL - MAIN MODULE')
  
  submodule.loggerCall()
  </code></pre>
  
  <p><strong>submodule.py</strong></p>
  
  <pre><code>import logging
  from logging.handlers import RotatingFileHandler
  
  
  def loggerCall():
      logger = logging.getLogger(__name__)
  #    logger.setLevel(logging.DEBUG)
  
      fh = RotatingFileHandler('master.log', maxBytes=2000000, backupCount=10)
      formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
      fh.setFormatter(formatter)
      logger.addHandler(fh)
  
      logger.debug('SUBMODULE: DEBUG LOGGING MODE : ')
      logger.info('Submodule: INFO LOG')
  
      return
  </code></pre>
  
  <p>I thought as longs as I call the getLogger from my submodule, it should inherit the log level &amp; handler details from root logger. However, in my case, I have to specify log level and handler again in submodule to get them print to same log file. </p>
  
  <p>Also, If I have lots of methods, and classes inside my submodule. How can I go about it without having to define my log level &amp; handler again. </p>
  
  <p>Idea is to have a single log file with main, and sub modules printing in the same log based on the log level set in the main module. </p>
  
  <p><strong>Thanks in advance</strong></p>
  
  <p><em>I am sorry, as this could be a duplicate question and I did go through those similar questions, but couldn't figure out how this works. Hence posting this question. I am not intentionally creating a duplicate bcz I didn't lookup for it.</em></p>