Python: How to override default logging handler?
<p>Suppose I have got a logger like:</p>

<pre><code>logger = logging.getLogger(__name__)
</code></pre>

<p>Then I add a file handler to it. I want all logs go to the file and all info and above log to be printed on screen.</p>

<p>I know I should set the level of the file handler to logging.INFO.</p>

<p>However, if I use <code>logger.setLevel(logging.INFO)</code>, then the debug logs won't go to the file. If I use <code>logger.setLevel(logging.DEBUG)</code>, then all debug logs will be printed on screen.</p>

<p>How to solve this problem?</p>