public static void DoLogToFile(bool done, string logfile) { if (done) { if (stream != null) { Log.Warning("Log.DoLogToFile can be invoked only once"); return; } try { BackupPrevLogs(logfile, MAX_BACKUP_LOGFILE_NUM); stream = new StreamWriter(FileUtils.OpenWrite(logfile)); } catch (Exception e) { Log.Warning("Can not open file {0} for log, {1}", logfile, e); return; } if (memoryLog != null) { memoryLog.MoveMemoryLogToFile(stream); memoryLog = null; } OnLogEvent += OnLogToFile; } else { OnLogEvent -= OnLogToFile; } }