private void ProcessLoop() { TimeSpan waitForExitTimeSpan = new TimeSpan(0); while (true) { try { LogMessage log = LogManagement.Instance().GetLog(new TimeSpan(0, 0, 0, 0, this.milliSecondsToGetLog)); if (log != null) { Logger logger = log.LogActor; ILogDistination distination = LogManagement.Instance().GetDistination(logger.Config); distination.Write(log); // to write all log continue; } } // just catch timeout exception, if timeout, do nothing. catch (TimeoutException) { } // thread need to exit if (this.exitEvent.WaitOne(waitForExitTimeSpan, false)) { break; } } }
internal ILogDistination GetDistination(LogConfigBase config) { lock (logDistinationMap) { ILogDistination distination = null; if (!logDistinationMap.ContainsKey(config.Type)) { distination = config.CreateDistination(); logDistinationMap.Add(config.Type, distination); } else { distination = logDistinationMap[config.Type]; } return(distination); } }