title: Why do my log messages appear in root logging file twice?
body: <p>I have script.py file in which I import requests module. I have noticed that by using root logger at the level DEBUG, I can log all GET requests which is nice.</p>
  <p>But I would like to have another log file to log other messages at INFO level. So I did this:</p>
  <pre><code># root logger to log all GET requests
  import logging
  logging.basicConfig(filename= &quot;allrequests.log&quot;, level=logging.DEBUG, 
                      format='%(asctime)s: %(levelname)s: %(message)s')
  
  # second logger to log only INFO
  formatter = logging.Formatter('%(asctime)s: %(levelname)s: %(message)s')
  handler = logging.FileHandler('onlyinfo.log')
  info_logger = logging.getLogger('second_logger')
  info_logger.setLevel(logging.INFO)
  info_logger.addHandler(handler)
  </code></pre>
  <p>the problem is now, whenever I use:</p>
  <pre><code>info_logger.info('my message')
  </code></pre>
  <p>it will log it twice in the first log file and once in the second file.</p>
  <p>It would be fine, if it only logs info messages once in each file.</p>
  <p>In other words I would like to log all messages (DEBUG and INFO level messages) in one log file and only INFO messages in another log file. How can I do this?</p>