读取事件日志

发布于 2024-08-21 22:57:50 字数 837 浏览 6 评论 0原文

我正在尝试从服务器上的事件日志中读取..我当前的代码正在运行..

但我担心的是,当事件中有数千个条目时,加载页面会需要更长的时间吗?

这是我的工作代码,

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一场信仰旅途 2024-08-28 22:57:50

如果有数千个条目,加载页面绝对需要更长的时间。您可能需要考虑使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文