本文整理汇总了C#中NLog.LogReceiverService.NLogEvents.ToEventInfo方法的典型用法代码示例。如果您正苦于以下问题:C# NLogEvents.ToEventInfo方法的具体用法?C# NLogEvents.ToEventInfo怎么用?C# NLogEvents.ToEventInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NLog.LogReceiverService.NLogEvents
的用法示例。
在下文中一共展示了NLogEvents.ToEventInfo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToLogEventInfoTest
public void ToLogEventInfoTest()
{
var events = new NLogEvents
{
BaseTimeUtc = new DateTime(2010, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).Ticks,
ClientName = "foo",
LayoutNames = new StringCollection { "foo", "bar", "baz" },
Strings = new StringCollection { "logger1", "logger2", "logger3", "zzz", "message1" },
Events =
new[]
{
new NLogEvent
{
Id = 1,
LevelOrdinal = 2,
LoggerOrdinal = 0,
TimeDelta = 30000000,
MessageOrdinal = 4,
Values = "0|1|2"
},
new NLogEvent
{
Id = 2,
LevelOrdinal = 3,
LoggerOrdinal = 2,
MessageOrdinal = 4,
TimeDelta = 30050000,
Values = "0|1|3",
}
}
};
var converted = events.ToEventInfo();
Assert.Equal(2, converted.Count);
Assert.Equal("message1", converted[0].FormattedMessage);
Assert.Equal("message1", converted[1].FormattedMessage);
Assert.Equal(new DateTime(2010, 1, 1, 0, 0, 3, 0, DateTimeKind.Utc), converted[0].TimeStamp.ToUniversalTime());
Assert.Equal(new DateTime(2010, 1, 1, 0, 0, 3, 5, DateTimeKind.Utc), converted[1].TimeStamp.ToUniversalTime());
Assert.Equal("logger1", converted[0].LoggerName);
Assert.Equal("logger3", converted[1].LoggerName);
Assert.Equal(LogLevel.Info, converted[0].Level);
Assert.Equal(LogLevel.Warn, converted[1].Level);
Layout fooLayout = "${event-context:foo}";
Layout barLayout = "${event-context:bar}";
Layout bazLayout = "${event-context:baz}";
Assert.Equal("logger1", fooLayout.Render(converted[0]));
Assert.Equal("logger1", fooLayout.Render(converted[1]));
Assert.Equal("logger2", barLayout.Render(converted[0]));
Assert.Equal("logger2", barLayout.Render(converted[1]));
Assert.Equal("logger3", bazLayout.Render(converted[0]));
Assert.Equal("zzz", bazLayout.Render(converted[1]));
}
示例2: ProcessLogMessages
public void ProcessLogMessages(NLogEvents nevents)
{
var events = nevents.ToEventInfo("Client.");
Console.WriteLine("in: {0} {1}", nevents.Events.Length, events.Count);
foreach (var ev in events)
{
var logger = LogManager.GetLogger(ev.LoggerName);
logger.Log(ev);
}
}
示例3: NoLayoutsTest
public void NoLayoutsTest()
{
var events = new NLogEvents
{
BaseTimeUtc = new DateTime(2010, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).Ticks,
ClientName = "foo",
LayoutNames = new StringCollection(),
Strings = new StringCollection { "logger1", "logger2", "logger3", "zzz", "message1" },
Events =
new[]
{
new NLogEvent
{
Id = 1,
LevelOrdinal = 2,
LoggerOrdinal = 0,
TimeDelta = 30000000,
MessageOrdinal = 4,
Values = null,
},
new NLogEvent
{
Id = 2,
LevelOrdinal = 3,
LoggerOrdinal = 2,
MessageOrdinal = 4,
TimeDelta = 30050000,
Values = null,
}
}
};
var converted = events.ToEventInfo();
Assert.Equal(2, converted.Count);
Assert.Equal("message1", converted[0].FormattedMessage);
Assert.Equal("message1", converted[1].FormattedMessage);
Assert.Equal(new DateTime(2010, 1, 1, 0, 0, 3, 0, DateTimeKind.Utc), converted[0].TimeStamp.ToUniversalTime());
Assert.Equal(new DateTime(2010, 1, 1, 0, 0, 3, 5, DateTimeKind.Utc), converted[1].TimeStamp.ToUniversalTime());
Assert.Equal("logger1", converted[0].LoggerName);
Assert.Equal("logger3", converted[1].LoggerName);
Assert.Equal(LogLevel.Info, converted[0].Level);
Assert.Equal(LogLevel.Warn, converted[1].Level);
}
示例4: ExtractLogEvents
private static List<LogEvent> ExtractLogEvents(NLogEvents events, Batch batch)
{
var logEventInfoList = events.ToEventInfo().ToList();
var timberMillEvents = logEventInfoList.ConvertAll(ei => TimberMillEventFactory(batch, ei));
return timberMillEvents;
}