title: How to use Python's RotatingFileHandler
body: <p>I'm trying to do a test run of the <code>logging</code> module's <code>RotatingFileHandler</code> as follows:</p>
  
  <pre><code>import logging
  from logging.handlers import RotatingFileHandler
  
  # logging.basicConfig(filename="example.log", level=logging.DEBUG)
  
  logger = logging.getLogger('my_logger')
  handler = RotatingFileHandler("my_log.log", maxBytes=2000, backupCount=10)
  logger.addHandler(handler)
  
  for _ in range(10000):
      logger.debug("Hello, world!")
  </code></pre>
  
  <p>However, with <code>logging.basicConfig</code> line commented out, the resulting <code>my_log.log</code> file contains no data:</p>
  
  <p><a href="https://i.stack.imgur.com/Q3CoP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Q3CoP.png" alt="enter image description here"></a></p>
  
  <p>If I comment in the line with <code>logging.basicConfig(filename="example.log", level=logging.DEBUG)</code>, I get the expected <code>my_log.log</code> files with numbered suffixes. However, there is also the <code>example.log</code> which is a (relatively) large file:</p>
  
  <p><a href="https://i.stack.imgur.com/J77C7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/J77C7.png" alt="enter image description here"></a></p>
  
  <p>How can I set up the logging so that it only generates the <code>my_log.log</code> files, and not the large <code>example.log</code> file?</p>