title: Python Logging Handler
body: <p>I want to add a userdefined variable to the logger format using ContextFiltering. My code is as follows :</p>
  
  <pre><code>import logging
  import logging.handlers
  CMDID='TEST'
  
  class ContextFilter(logging.Filter):
    def filter(self,record):
      record.CMDID=CMDID
      return True
  
  FORMAT='%(asctime)s [%(CMDID)s] - %(message)s'
  logger=logging.getLogger("Test")
  fh=logger.handlers.RotatingFileHandler("testing.log",maxBytes=1024,backupCount=5)
  fh.setlevel(logging.DEBUG)
  fh.setFormatter(logging.Formatter(FORMAT))
  logger.addHandler(fh)
  logger.addFilter(ContextFilter())
  logger.warning("WTH")
  </code></pre>
  
  <p>When I don't use a filehandler and just use a basicConfig for formatting then the code works fine. But on adding a Rotating File Handler I get error</p>
  
  <pre><code>Traceback (most recent call last):
  Line 16, in &lt;module&gt;
  fh=logger.handlers.RotatingFileHandler("testing.log",maxBytes=1024,backupCount=5)
  AttributeError: 'list' object has no attribute 'RotatingFileHandler'
  </code></pre>
  
  <p>Now I have also tried using LoggerAdapters class for this, but it also throws weird errors which on further investigation I found out that there might be some issues with its documentation.</p>
  
  <p>Can anyone help me regarding this issue and suggest me a way to effectively add contextual user defined info in my logger using this FileHandler.</p>
  
  <p>P.S. I have tried the methods given in the python doc to no use</p>