我正在尝试读取服务器上的事件日志。我当前的代码正在运行..
但我担心的是,当事件中有数千个条目时,加载页面会花费更长的时间吗?
以下是我的工作代码
ArrayList chromeEntries = new ArrayList();
EventLog eventLog = new EventLog("Application", ".");
foreach (EventLogEntry logEntry in eventLog.Entries)
{
if (logEntry.Source.Equals("Application Error"))
{
chromeEntries.Add(logEntry.TimeWritten);
}
}
GridView1.DataSource = chromeEntries;
GridView1.DataBind();我想要显示应用程序日志中的时间条目,这些日志的源名称为"Application Error“。我唯一关心的是每一个...??我的担忧是正确的吗?或者上面的代码就可以了..
有什么建议吗
谢谢
好的,我试过了
EventLog eventLog = new EventLog("Application", ".", "Application Error");
Label1.Text = eventLog.Entries.Count.ToString();但它会计算整个条目,而不是仅计算应用程序错误的条目
发布于 2010-02-17 01:18:46
如果有数千个条目,则加载页面所需的时间绝对会更长。您可能希望考虑使用WMI to query the log,而不是只遍历所有内容。
https://stackoverflow.com/questions/2274793
复制相似问题