/// <summary> /// 日志输出 /// </summary> /// <param name="logItem">要输出的日志项</param> internal void OnRaiseLogOutput(RedirectOuputItem logItem) { try { if (!string.IsNullOrEmpty(this._loggerName) && !string.Equals(this._loggerName, logItem.Item.LogerName)) { //日志记录器名称不为空或null,且与产生日志的日志记录器名称不匹配,直接返回 return; } if (!string.IsNullOrEmpty(this._appenderName) && !string.Equals(this._appenderName, logItem.AppenderName)) { //日志重定制追加器名称不为空或null,且与重定向日志追加器名称不匹配,直接返回 return; } var handler = this._logOutput; if (handler == null || logItem == null) { //重定向委托为空,直接返回 return; } handler(logItem); } catch (Exception ex) { LogSysInnerLog.OnRaiseLog(this, ex); } }
/// <summary> /// 日志输出 /// </summary> /// <param name="logItem"></param> private static void LogOutput(RedirectOuputItem logItem) { RedirectOutputChannel[] redirectOutputChannelArr; lock (_logOutputSubscribeItemListMonitor) { redirectOutputChannelArr = _logOutputSubscribeItemList.ToArray(); } foreach (var redirectOutputChannel in redirectOutputChannelArr) { redirectOutputChannel.OnRaiseLogOutput(logItem); } }