是否可以使用'light'是否可以为EventLogquery编写查询。
我需要过滤并说例如packagefullname应该以'6'开头,如何使用某种模式过滤?
string query = "*[System/EventID=400 ] and *[System/Opcode=2] and *[EventData[Data[@Name='PackageFullName'] LIKE '6%']]";
I need to filter and say for example PackageFullName should start with '6', how filter using some pattern?
string query = "*[System/EventID=400 ] and *[System/Opcode=2] and *[EventData[Data[@Name='PackageFullName'] LIKE '6%']]";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如评论中所述,Windows上的事件日志服务确实不是支持完整的XPath语法 - 它当然不支持诸如
contains()
/start-with()
/end-with()
。相反,您需要获取所有事件,然后通过在您自己的代码中检查数据值来过滤它们。
要从事件数据部分中提取单个
< data/>
节点的值,请使用getPropertyValues()值,然后手动检查它:
As explained in the comments, the Event Log service on Windows does not support the full XPath grammar - and it certainly doesn't support substring-matching functions like
contains()
/starts-with()
/ends-with()
.Instead, you'll need to fetch all the events and then filter them by inspecting the data value in your own code.
To extract the individual
<Data />
nodes' values from the event data section, use theGetPropertyValues()
method with an appropriateEventLogPropertySelector
to grab the string value, then manually inspect it: