title: How to disable python logging stdout and have it just inside the log file
body: <p>I want to disable my script to print the <code>INFO</code>, <code>DEBUG</code>, <code>WARNING</code> or <code>ERROR</code> from logging commands and just have this inside the <code>.log</code> or <code>.err</code>. Here is the configuration I have:</p>
  <pre><code>def log(routine_name):
      &quot;&quot;&quot; Logging configuration &quot;&quot;&quot;
      logger = logging.getLogger(_name_)
      logger.setLevel(logging.INFO)
      logging.StreamHandler(stream=None)
  
      formatter = logging.Formatter(&quot;%(asctime)s:%(levelname)s:%(name)s:%(message)s&quot;)
  
      file_handler = logging.FileHandler(routine_name)
      file_handler.setFormatter(formatter)
  
      error_handler = logging.FileHandler(routine_name.replace(&quot;log&quot;, &quot;err&quot;))
      error_handler.setFormatter(formatter)
      error_handler.setLevel(logging.ERROR)
  
      stream_handler = logging.StreamHandler()
      stream_handler.setFormatter(formatter)
  
      logger.addHandler(file_handler)
      logger.addHandler(stream_handler)
      logger.addHandler(error_handler)
      
      return logger
  </code></pre>
  <p>I have tried to set <code>logger.propagate = False</code> from this <a href="https://stackoverflow.com/questions/37460714/python-logging-disable-output-to-stdout">post</a> but didn't work, it still printing everything.</p>
  <p>Thanks</p>