title: Setting logging levels in logging.conf in Python
body: <p>I am trying to make it easy to debug my code as my project grows.  I hate adding and removing print or debug statements (why not just leave them in?)   The problem is the output becomes messy to read.  I am trying to be able to set up logging in different files and levels so I can turn it on or off via the logging.conf configuration file.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import logging.config
  logging.config.fileConfig('logging.conf')
  if __name__ == "__main__":
      one = logging.getLogger("oneLogger")
      two = logging.getLogger("twoLogger")
      one.debug("debug on one")
      one.info("info on one")
      one.warn("warn on one")
      one.error("error on one")
      one.critical("critical on one")
      two.debug("debug on two")
      two.info("info on two")
      two.warn("warn on two")
      two.error("error on two")
      two.critical("critical on two")
  </code></pre>
  
  <p>Here is my logging.conf file:</p>
  
  <pre><code>[loggers]
  keys=root,oneLogger, twoLogger
  
  [handlers]
  keys=rootHandler, oneHandler, twoHandler
  
  [formatters]
  keys=rootFormatter,oneFormatter, twoFormatter
  
  [logger_root]
  level=DEBUG
  handlers=rootHandler
  
  [logger_oneLogger]
  level=DEBUG
  handlers=oneHandler
  qualname=main
  propagate=1
  
  [logger_twoLogger]
  level=CRITICAL
  handlers=twoHandler
  qualname=main
  propagate=1
  
  [handler_rootHandler]
  class=StreamHandler
  formatter=rootFormatter
  args=(sys.stdout,)
  
  [handler_oneHandler]
  class=StreamHandler
  formatter=oneFormatter
  args=(sys.stdout,)
  
  [handler_twoHandler]
  class=StreamHandler
  formatter=twoFormatter
  args=(sys.stdout,)
  
  [formatter_rootFormatter]
  format=Root: %(asctime)s - %(name)s - %(levelname)s - %(message)s
  datefmt=
  
  [formatter_oneFormatter]
  format=One: %(asctime)s - %(name)s - %(levelname)s - %(message)s
  datefmt=
  
  [formatter_twoFormatter]
  format=Two: %(asctime)s - %(name)s - %(levelname)s - %(message)s
  datefmt=
  </code></pre>
  
  <p>I would have expected this output:</p>
  
  <pre><code>One: 2016-12-22 16:36:32,414 - one - DEBUG - debug on one
  One: 2016-12-22 16:36:32,414 - one - INFO - info on one
  One: 2016-12-22 16:36:32,415 - one - WARNING - warn on one
  One: 2016-12-22 16:36:32,417 - one - ERROR - error on one
  One: 2016-12-22 16:36:32,417 - one - CRITICAL - critical on one
  Two: 2016-12-22 16:36:32,421 - two - CRITICAL - critical on two
  </code></pre>
  
  <p>Instead I got this:</p>
  
  <pre><code>Root: 2016-12-22 16:36:32,414 - one - DEBUG - debug on one
  Root: 2016-12-22 16:36:32,414 - one - INFO - info on one
  Root: 2016-12-22 16:36:32,415 - one - WARNING - warn on one
  Root: 2016-12-22 16:36:32,417 - one - ERROR - error on one
  Root: 2016-12-22 16:36:32,417 - one - CRITICAL - critical on one
  Root: 2016-12-22 16:36:32,418 - two - DEBUG - debug on two
  Root: 2016-12-22 16:36:32,418 - two - INFO - info on two
  Root: 2016-12-22 16:36:32,420 - two - WARNING - warn on two
  Root: 2016-12-22 16:36:32,421 - two - ERROR - error on two
  Root: 2016-12-22 16:36:32,421 - two - CRITICAL - critical on two
  </code></pre>
  
  <p>I was expecting that logger two would be limited to only CRITICAL logs and logger one would accept all logs. Instead, I was surprised to see that the root logger handled ALL of the logs.</p>
  
  <p>What am I doing/assuming wrong?</p>