简体   繁体   English

python中如何写入ETW事件日志?

[英]How to write ETW event logs in python?

In c#, we can see ETW event logs in 'Diagnostic Events viewer' by configing some Eventsources.在 c# 中,我们可以通过配置一些事件源在“诊断事件查看器”中看到 ETW 事件日志。 Now I want to implement the same function(write ETW event logs) in python, can anyone give me some suggestions?现在我想在 python 中实现相同的功能(写入 ETW 事件日志),有人可以给我一些建议吗?

I have use win32evtlogutil.ReportEvent() to write some Windows Event Logs, and can see these logs in 'Event Viewer'-'Windows Logs'-'Application and Services Logs', but the ETW events are different from the Windows Event Logs, the ETW events cannot be seen in 'Event Viewer'.我已经使用 win32evtlogutil.ReportEvent() 编写了一些 Windows 事件日志,并且可以在“事件查看器”-“Windows 日志”-“应用程序和服务日志”中看到这些日志,但 ETW 事件与 Windows 事件日志不同,在“事件查看器”中看不到 ETW 事件。 I also have used the pywintrace, but it can not write event logs, it only captures events, so it does not meet my requirements. pywintrace我也用过,但是不能写事件日志,只能抓事件,不符合我的要求。

You may want to check-out PyEtw .您可能想要签出PyEtw PyEtw uses Pythons standard logging facility, and implements a handler that writes the records as ETW events via Microsoft TraceLogging. PyEtw 使用 Python 的标准日志记录工具,并实现一个处理程序,通过 Microsoft TraceLogging 将记录写入 ETW 事件。

Note that the provider GUID is automatically derived from the logger name, so you need to prefix the tracelog -guid option argument with a star, for instance -guid *root for the root logger.请注意,提供者 GUID 是从记录器名称自动派生的,因此您需要在-guid选项参数前加上星号,例如-guid *root表示root记录器。

GitHub repo and examples can be found here: https://github.com/mgtek/pyetw GitHub repo 和示例可以在这里找到: https://github.com/mgtek/pyetw

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

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