读取特定源的Windows事件日志 [英] read the windows event log by particular Source

查看:98
本文介绍了读取特定源的Windows事件日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何可以读取特定的来源,日期时间和类别?Windows事件日志

How can i read the windows event log by particular Source, Date time and category??

推荐答案

我知道这个问题是强大了,但我花了很多的时间现在建立一个解决的办法,所以我想我会分享:

I know this question is mighty old, but I spent a good deal of time today building a solution to this so I thought I would share:

        Dim myEventLogEntryCollection As EventLogEntryCollection = New EventLog("Application", System.Environment.MachineName).Entries

        Dim myEventLogEntryArray(myEventLogEntryCollection.Count - 1) As EventLogEntry

        myEventLogEntryCollection.CopyTo(myEventLogEntryArray, 0)

        Dim QueryLog As System.Linq.IQueryable(Of EventLogEntry) = myEventLogEntryArray.AsQueryable

        QueryLog = QueryLog.Where(Function(i As EventLogEntry) i.Source = "MyParticularSourceName")

        For Each Entry As EventLogEntry In QueryLog

            '... your code goes here

        Next

        myEventLogEntryCollection = Nothing
        myEventLogEntryArray = Nothing

希望它可以帮助别人!

Hope it helps others!

这篇关于读取特定源的Windows事件日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆