title: Python. Redirect stderr to log file
body: <p>I have Django web-site working on tornado and nginx.</p>
  
  <p>I took this tornado launcher <a href="http://pysi.org/articles/django_and_tornado/" rel="nofollow">script</a> (tornading.py)</p>
  
  <p>Then I'm using python openid that outputs some information to sys.stderr.</p>
  
  <p>As a result I get IOError.</p>
  
  <p>How can I redirect it using logging package?</p>
  
  <p>I thought about </p>
  
  <pre><code>f = open("myfile.log", "w")
  sys.stderr = f
  </code></pre>
  
  <p>or </p>
  
  <pre><code>python tornado.py &gt; /dev/null 2&gt;&amp;1
  </code></pre>
  
  <p>But what is the best way to solve it?</p>