/// <summary> /// 使用list来保存活动logworker,并且使用另外的线程来close niut /// 以此来实现动态管理 /// </summary> /// <param name="FullPath"></param> /// <returns></returns> private FileLogWorker GetFileLogWorker(string FullPath) { try { return(_Workers[FullPath]); } catch { lock (typeof(LocalLockObject)) { if (_Workers.ContainsKey(FullPath) == false) { FileLogWorker theWorker = new FileLogWorker(FullPath); _Workers.Add(FullPath, theWorker); return(theWorker); } else { return(_Workers[FullPath]); } } } }
/// <summary> /// 向文件日志写日志内容 /// </summary> /// <param name="fileName">日志文件名</param> /// <param name="logContent">日志内容</param> public void WriteLogFile(string fileName, string logContent) { FileLogWorker theWorker = GetFileLogWorker(fileName); theWorker.WriteLogContent(logContent); }