/// <summary> /// 启动日志记录 /// </summary> public override void Start() { //**********VERSION 1.1.2.0 START**********// if (_thread != null) { _thread.Start(); return; } //**********VERSION 1.1.2.0 END**********// LogPersistenceService.SetPersistParam(LogFormatter.GetLogFileName(TXTLogFactory.GetLogFileName(LogConfig))); //**********VERSION 1.1.2.0 START**********// _thread = new Thread(Run) { IsBackground = true }; _thread.Start(); //new Thread(Run).Start(); //**********VERSION 1.1.2.0 END**********// }
/// <summary> /// 执行日志记录 /// </summary> /// <exception cref="GeneralException"></exception> protected void Run() { try { do { ProcessIsClosed = false; Thread.Sleep(LogPersistInterval); if (LogRecordList.Count > 0) { LogPersistenceService.Save(LogRecordList); } } while (ProcessIsBegin || LogRecordList.Count > 0); } catch (Exception ex) { throw ExceptionHelper.GetException(20002001, "TXTLogService", ex); } finally { ProcessIsBegin = false; ProcessIsClosed = true; } }