【发布时间】:2011-03-10 01:04:25
【问题描述】:
我正在尝试读取我的应用程序 EventLoggingApp 的事件日志。问题是读取我的单一来源(EventLoggingApp)的日志。
此代码读取每个来源的日志。问题是什么?有什么建议吗?
static void ReadEvenLog()
{
string eventLogName = "Application";
string sourceName = "EventLoggingApp";
string machineName = "Tom";
EventLog eventLog = new EventLog();
eventLog.Log = eventLogName;
eventLog.Source = sourceName;
eventLog.MachineName = machineName;
foreach (EventLogEntry log in eventLog.Entries)
{
Console.WriteLine("{0}\n",log.Source);
}
}
【问题讨论】: