本文整理汇总了C#中System.Diagnostics.EventLog.GetEntriesSince方法的典型用法代码示例。如果您正苦于以下问题:C# EventLog.GetEntriesSince方法的具体用法?C# EventLog.GetEntriesSince怎么用?C# EventLog.GetEntriesSince使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.EventLog
的用法示例。
在下文中一共展示了EventLog.GetEntriesSince方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenAReconfigurationErrorIsNotified_ThenItIsLoggedThroughWmi
public void WhenAReconfigurationErrorIsNotified_ThenItIsLoggedThroughWmi()
{
DateTime testStartTime = DateTime.Now;
Thread.Sleep(1500); // Log granularity is to the second, force us to the next second
using (var eventLog = new EventLog("Application", ".", "Enterprise Library Logging"))
{
this.provider.FireReconfigurationErrorEvent(new Exception("test message"));
var entries =
eventLog.GetEntriesSince(testStartTime).Where(entry => entry.Message.IndexOf("test message") > -1);
Assert.AreEqual(0, entries.Count());
}
}
示例2: CreatingDatabaseWithUnknownInstanceNameWritesToEventLog
public void CreatingDatabaseWithUnknownInstanceNameWritesToEventLog()
{
var startTime = DateTime.Now;
Thread.Sleep(1000);
try
{
Database db = DatabaseFactory.CreateDatabase("ThisIsAnUnknownKey");
}
catch (ActivationException)
{
using (EventLog applicationLog = new EventLog("Application"))
{
var entries = applicationLog.GetEntriesSince(startTime)
.Where(e => e.Source == "Enterprise Library Data" &&
e.Message.Contains("ThisIsAnUnknownKey"));
Assert.AreEqual(1, entries.Count());
}
return;
}
Assert.Fail("ActivationException expected");
}