title: Logging in Python with Config File - Using handlers defined in file through code
body: <p>I am using logging module of python. How can I access the handlers defined in config file from the code. As an example, I have a logger defined and two handlers - one for screen and other for file. I want to use appropriate handler based on user preference (whether they want to log on screen or to a file). How can I dynamically add and remove handlers defined in config file from loggers defined in config file?</p>
  
  <pre><code>[loggers]
  
  keys=root,netmap
  
  [handlers]
  keys=fil,screen
  
  [logger_root]
  level=NOTSET
  handlers=
  
  [logger_netmap]
  level=INFO
  handlers=fil,screen
  qualname=netmap
  
  [formatters]
  keys = simple
  
  [formatter_simple]
  format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
  datefmt=
  
  [handler_fil]
  class=handlers.RotatingFileHandler
  args=('file.log','a','maxBytes=10000','backupCount=5')
  formatter=simple
  
  [handler_screen]
  class=StreamHandler
  args = (sys.stdout,)
  formatter=simple
  </code></pre>
  
  <p>Depending on whether user runs the program with -v or not I need to use one of File or Screen Handler. How can I add or delete fil or screen handlers from netmap logger?</p>