简体   繁体   English

读取事件日志

[英]reading an event log

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...?? 我想在源名称为“ Application Error”的应用程序日志中显示时间条目。我唯一关心的是每个... 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 但它会计算整个条目,而不仅仅是对应用程序错误进行计数

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. 您可能要考虑使用WMI查询日志,而不是仅遍历所有内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM