title: How to set logging level in a unit test for Python
body: <p>I am running a particular unit test in my library, and I would like to get more logging from it. I am running it in the following way:</p>
  
  <pre><code>python -m unittest my_module.my_submodule_test.MyTestClass.test_my_testcase
  </code></pre>
  
  <p>Because I'm doing this, the <code>my_submodule_test.py</code> file does not run the bottom part where I set the log level like so:</p>
  
  <pre><code>if __name__ == '__main__':
    logging.getLogger().setLevel(logging.DEBUG)
    unittest.main()
  </code></pre>
  
  <p>How can I programatically set the log level so that I can get more detailed logging from my test? </p>
  
  <p>Also, I'd like to be able to set the logging via a command-line argument. Is there a way to do that?</p>