'Create file handler which logs to file.'

def setlogfile(self, logfile):

    fh = logging.FileHandler(logfile, 'at')
    file_formatter = logging.Formatter('%(asctime)s    %(levelname)s:    %(message)s', '%Y-%m-%d    %H:%M:%S')
    fh.setFormatter(file_formatter)
    self.logger.addHandler(fh)
    p_ver = '.'.join([str(x) for x in sys.version_info[0:3]])
    msg = ('OfflineImap    %s    starting...\n        Python:    %s    Platform:    %s\n        Args:    %s' % (offlineimap.__version__, p_ver, sys.platform, '    '.join(sys.argv)))
    record = logging.LogRecord('OfflineImap', logging.INFO, __file__, None, msg, None, None)
    fh.emit(record)
