コード例 #1
0
 public void Send(ILogger log, IMonitoringItem monitoringItem)
 {
     if (_monitoringOptions.EnableMonitoring)
     {
         foreach (var destination in _destinations)
         {
             destination.SendOneItem(log, monitoringItem);
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Отправка item в лог
        /// </summary>
        /// <param name="log">логгер</param>
        /// <param name="monitoringItem">item</param>
        public void SendOneItem(ILogger log, IMonitoringItem monitoringItem)
        {
            var wrappedItem = new MonitoringItemWrapper <IMonitoringItem>(monitoringItem, _commonMonitoringSet);
            var loggerName  = $"{_prefix}.{log.Name}";

            //loggers are cached in NLog core
            var jsonLog = LogManager.GetLogger(loggerName);

            var theEvent = new LogEventInfo()
            {
                Level = LogLevel.Info
            };

            theEvent.Properties["class"]  = log.Name;
            theEvent.Properties["Detail"] = wrappedItem.GetJson();

            jsonLog.Log(theEvent);
        }