本文整理汇总了C#中log4net.Core.LoggingEvent.First方法的典型用法代码示例。如果您正苦于以下问题:C# LoggingEvent.First方法的具体用法?C# LoggingEvent.First怎么用?C# LoggingEvent.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类log4net.Core.LoggingEvent
的用法示例。
在下文中一共展示了LoggingEvent.First方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendBuffer
protected override void SendBuffer(LoggingEvent[] events)
{
var newEvents = events
.ToList()
.Where(ev => Evaluator.IsTriggeringEvent(ev))
.ToList();
// Se è passato l'intervallo prende il primo
if (FlushInterval.TotalMilliseconds >= 0 && DateTime.Now - _lastFlush > FlushInterval)
{
newEvents = new List<LoggingEvent> {events.First()};
// Se c'è specificato un filtro allora filtra
if (!string.IsNullOrEmpty(IgnoreIfWordsInSubjectOrBody))
{
var items = IgnoreIfWordsInSubjectOrBody.Split(',').Select(el => el.ToLower()).ToList();
// Se una parola è contenuta nell'oggetto o nel testo del messaggio viene scartato il messaggio
var filteredEvents = new List<LoggingEvent>();
foreach (var loggingEvent in newEvents)
{
var subject = RenderSubject(loggingEvent);
var message = loggingEvent.RenderedMessage;
if (!items.Any(el => subject.ToLower().Contains(el) && !message.ToLower().Contains(el)))
filteredEvents.Add(loggingEvent);
}
newEvents = filteredEvents;
}
if (newEvents.Count > 0)
{
var subjects = newEvents.Select(RenderSubject);
Subject = string.Join(", ", subjects);
base.SendBuffer(newEvents.ToArray());
_lastFlush = DateTime.Now;
}
}
}