title: Python logging module doesn't write in log file
body: <p>I have an issue with my script, I'm trying to create a log file for every call of this function:</p>
  
  <pre><code>@begin.subcommand
  def sample_mode(sample, folder = None, reference = None, dbsnp = None):
      """ creates a config file for 1 sample
  
      - setup logging system: {folder}/logs/{sample}_init.log
      - takes in a sample name
      - creates a file: {folder}/{sample}_config.yaml
      """
      # get the current folder if none is given
      if folder == None:
          folder = os.getcwd() 
  
      # create logs folder if necessary
      if not os.path.isdir("{}/logs".format(folder)):
          os.mkdir("{}/logs".format(folder))
  
      log_file = setup_log(sample, folder)
  
      for i in range(1,3):
          try:
              os.path.getsize("{}/{}.{}.fq.gz".format(folder, sample, i))
          except FileNotFoundError:
              log_file.error("{}/{}.{}.fq.gz doesn't exist".format(folder, sample, i))
              return -1
  
          if os.path.getsize("{}/{}.{}.fq.gz".format(folder, sample, i)) == 0:
              log_file.error("\"{}/{}.{}.fq.gz\" is empty\n".format(folder, sample, i))
              return -1
  
      # set up logging system
      # logging.basicConfig(filename = "{}/logs/{}_init.log".format(folder, sample), level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
  
      # create the config file
      with open("{}/{}_config.yaml".format(folder, sample), "w") as config:
          config.write("sample: \"{}\"\n\n".format(sample))
          log_file.info("Sample name: {}".format(sample))
  </code></pre>
  
  <p>For reference, the setup_log function:</p>
  
  <pre><code>def setup_log(sample, folder):
      logger = logging.getLogger(__name__)
  
      log_format = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
  
      filename = "{}/logs/{}_init.log".format(folder, sample)
  
      log_handler = logging.FileHandler(filename)
      log_handler.setLevel(logging.DEBUG)
      log_handler.setFormatter(log_format)
  
      logger.addHandler(log_handler)
  
      return logger
  </code></pre>
  
  <p>The log file is created but it's empty. However, if i put a wrong sample name, the log file is created and the error message is written.</p>
  
  <p>What an i doing wrong?</p>