protected override async void SendBuffer(LoggingEvent[] events) { if (events == null || !events.Any()) { return; } CheckSession(); var logsEvents = events.Where(e => e != null).Select(e => new Log(e)); await Task.Run(() => { try { Parallel.ForEach(logsEvents, (entry) => { documentSession.Store(entry); }); documentSession.SaveChanges(); } catch (Exception e) { ErrorHandler.Error("Exception while commiting to the Raven DB", e, ErrorCode.GenericFailure); } }); }
protected override void Append(LoggingEvent[] loggingEvents) { var collection = GetCollection(CollectionName); IMongoCollection<BsonDocument> dualCollection = null; if (!string.IsNullOrWhiteSpace(DualCollectionName)) { dualCollection = GetCollection(DualCollectionName); } Task.Run(() => { collection.InsertManyAsync(loggingEvents.Select(BuildBsonDocument)); dualCollection?.InsertManyAsync( loggingEvents.Where(log => log.Level >= DualCollectionLevelThreshold).Select(BuildBsonDocument)); }); }
protected override void SendBuffer(LoggingEvent[] events) { var eventArray = events .Where(x => x.Level > Level.Debug) .Select(loggingEvent => new { agentName = Environment.MachineName, timestamp = loggingEvent.TimeStamp, time = loggingEvent.TimeStamp.ToString("hh:MM:ss"), level = loggingEvent.Level.ToString().ToLower(), message = loggingEvent.RenderedMessage, exception = loggingEvent.ExceptionObject != null ? loggingEvent.GetExceptionString() : null }).ToArray(); _nodeFrontPublisherPublisher.Notify("/agent/log", eventArray); }
protected override void SendBuffer(LoggingEvent[] events) { if (events == null || !events.Any()) { return; } this.CheckSession(); foreach (var entry in events.Where(e => e != null).Select(e => new Log(e))) { this.documentSession.Store(entry); } this.Commit(); }
/// <summary> /// Does the append. /// </summary> /// <param name="loggingEvents">The logging events.</param> public void DoAppend(LoggingEvent[] loggingEvents) { if (_stopForwarding) { ErrorHandler.Error(string.Concat("Attempted to append to closed appender named [", Name, "].")); return; } try { var filteredEvents = new List<LoggingEvent>(loggingEvents.Length); foreach (LoggingEvent loggingEvent in loggingEvents.Where(FilterEvent)) { loggingEvent.Fix = _fixedFields; filteredEvents.Add(loggingEvent); } if (filteredEvents.Count == 0) return; lock (_queueSynchro) { if (_eventQueue.Count == 0) Monitor.Pulse(_queueSynchro); _eventQueue.AddRange(filteredEvents); if (Interlocked.Add(ref _logEventsCounter, filteredEvents.Count) >= StopEnqueuingLogEventsThreshold && StopEnqueuingLogEventsThreshold != 0) { _discardLogEvents = true; LogLog.Warn("Queue is full, Events logged after this will be discarded."); } } } catch (Exception ex) { ErrorHandler.Error("Failed in Bulk DoAppend", ex); } }