code: def start_logging_to_file(self, program_name=None, log_dir=None):
      
      FLAGS.logtostderr = False
  
      actual_log_dir, file_prefix, symlink_prefix = find_log_dir_and_names(
          program_name=program_name, log_dir=log_dir)
  
      basename = '%s.INFO.%s.%d' % (
          file_prefix,
          time.strftime('%Y%m%d-%H%M%S', time.localtime(time.time())),
          os.getpid())
      filename = os.path.join(actual_log_dir, basename)
  
      if six.PY2:
        self.stream = open(filename, 'a')
      else:
        self.stream = open(filename, 'a', encoding='utf-8')
  
      # os.symlink is not available on Windows Python 2.
      if getattr(os, 'symlink', None):
        # Create a symlink to the log file with a canonical name.
        symlink = os.path.join(actual_log_dir, symlink_prefix + '.INFO')
        try:
          if os.path.islink(symlink):
            os.unlink(symlink)
          os.symlink(os.path.basename(filename), symlink)
        except EnvironmentError:
          # If it fails, we're sad but it's no error.  Commonly, this
          # fails because the symlink was created by another user and so
          # we can't modify it
          pass
docs: Starts logging messages to files instead of standard error.