title: Log progress statement to separate file
body: <p>I am using the logger from the standard library and would like to log a progress statement to its own file. I have the logger set up to log to both the console as well as a file. The setup looks like this.</p>
  
  <pre><code>def setup_logging(args):
    try:
      numeric_level = getattr(logging, args.loglevel.upper())
  
      # If they provide a full path, ensure that the path is valid.
      log_dir = os.path.dirname(args.logfile)
      if log_dir and not os.path.isdir(log_dir):
          # If the provided path doesn't exist, write the log file
          # using the provided name to the current directory
          args.logfile = os.path.basename(args.logfile)
          sys.stderr.write("Invalid logfile path. Defaulting to current directory\n")
  
      logging.basicConfig(level=numeric_level,
                          format='%(asctime)s - %(name)s - %(levelname)s - %(funcName)s - %(message)s',
                          datefmt='%m-%d-%Y %H:%M:%S',
                          filename=args.logfile,
                          filemode='w')
  
      console = logging.StreamHandler()
      console.setLevel(logging.ERROR)
      formatter = logging.Formatter('%(name)s - %(funcName)s - %(levelname)s - %(message)s')
      console.setFormatter(formatter)
      logging.getLogger('').addHandler(console)
  
     except Exception as e:
      logging.critical("Failed to configure logging for the following reason: %s", e.message)
      return False
  
     return True
  </code></pre>
  
  <p>This works great for logging to the the console and logging all statements of a given level or above to the file. The problem comes from the fact that I would like to log a progress statement (And only that statement) to a separate file. I am currently printing the statement to the console in  the following manner.</p>
  
  <pre><code>if current &lt; num_file:
      print("Processing file {:.0f} of {} ({:.2%} Completed)".format(current + 1, num_file, current/num_file),
                end='\r')
  
  else:
      print("Finished file {:.0f} of {} ({:.2%} Completed)".format(current, num_file, current/num_file))
  </code></pre>
  
  <p>Unfortunately this statement doesn't seem to print on all consoles and gets overwritten when the logger logs an error statement to the console. Because of this I'd like to additionally write the statement to a file. </p>
  
  <p>I know that I could use the following to accomplish this, but I'm wondering if there is a way to do it using the logging library. Id rather not have to worry about dealing with the file myself if it can be avoided.</p>
  
  <pre><code>prog_file = open("progress.txt", 'w') 
  
  ...
  
  print("Processing file {:.0f} of {} ({:.2%} Completed)".format(current + 1, num_file, current/num_file),
                end='\r', file=prog_file)
  </code></pre>