title: how to set logging level from command line
body: <p>I'm using argparse to get the logging level from the command line and then passing it as input for logging.basicConfig. However, the way I'm trying to implement this is not working. Any suggestion?</p>
  <p>Desire behavior, from command line:</p>
  <pre><code>python main.py -log=DEBUG
  </code></pre>
  <p>Desire output</p>
  <pre><code>DEBUG:__main__: Debug is working
  </code></pre>
  <p>Code</p>
  <pre><code>import logging
  import argparse
  
  parser = argparse.ArgumentParser()
  parser.add_argument(&quot;-log&quot;, &quot;--log&quot;, nargs='+', help=&quot;Provide logging level. Example --log debug'&quot;)
  
  log_level = parser.parse_args().log
  log_level = 'logging.'+log_level[0]
  print(log_level)
  logging.basicConfig(level=log_level)
  logger = logging.getLogger(__name__) 
  logger.debug(' Debug is working')
  </code></pre>