读取事件日志
我正在尝试从服务器上的事件日志中读取..我当前的代码正在运行..
但我担心的是,当事件中有数千个条目时,加载页面会需要更长的时间吗?
这是我的工作代码,
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();
我想显示应用程序日志中的时间条目,其源名称为“应用程序错误”。 我唯一关心的是每个......?我的担心有效吗?或者上面的代码就很好..
任何建议
谢谢
,好的我尝试过这个,
EventLog eventLog = new EventLog("Application", ".", "Application Error");
Label1.Text = eventLog.Entries.Count.ToString();
但它计算整个条目,而不是只计算应用程序错误的条目
i am trying to read from the event logs on the server.. my current code is working..
but my worry is when there are thousands of entries in the events, will it take longer to load the page??
here is my working code
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();
i want to display the time entries in the application logs which have a source name of "Application Error"..
my only concern is for each...?? is my concern valid ? or the above code is just fine..
any suggestions
thanks
ok i tried this
EventLog eventLog = new EventLog("Application", ".", "Application Error");
Label1.Text = eventLog.Entries.Count.ToString();
but it counts the entire entries instead of just counting entries for Application Error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果有数千个条目,加载页面绝对需要更长的时间。您可能需要考虑使用 WMI 查询日志而不是仅仅迭代所有内容。
It will absolutely take substantially longer to load the page if there are thousands of entries. You might want to consider using WMI to query the log instead of just iterating through everything.