python-3.x - 如何为 win32evtlogutil.ReportEvent() 正确定义 eventID
问题描述
我尝试通过下一个代码将日志保存到 Windows 日志中:
win32evtlogutil.ReportEvent(GnrwDaemon.APP_NAME,
eventID=INFO_CODE_ID,
eventType=win32evtlog.EVENTLOG_INFORMATION_TYPE,
strings=n_data,
data=b'TestApp',
sid=my_sid)
哪里INFO_CODE_ID = 6146 # 0001 1000 0000 0010
。我使用指令定义了这个 eventID - https://docs.microsoft.com/en-us/windows/win32/eventlog/event-identifiers
但是当我检查服务日志时,我得到了错误:
I can't find a description for the event ID 6146 from the TestApp source. The component that causes this event is not installed on this local computer or is corrupted. Install or restore the component on the local computer.
我在powershell中运行脚本如下:
(python3 .\main.py install) -and (python .\main.py restart)
您能告诉我如何正确生成 eventID 以使 Windows 不会打印此错误吗?
除了这个问题,我也有一个。现在所有日志都被写入 Windows 日志(Журналы Windows),但我怎样才能将它们写入 Windows 的应用程序和服务日志(Журналы приложений и служб)(检查屏幕截图)?
解决方案
推荐阅读
- r - 将列名中具有多个键的数据框从宽变为长
- sql - 根据不同的行检索数据
- owin - 将 Application Insights cloud_RoleName 分配给使用 OWIN 运行的 Windows 服务
- business-intelligence - BOBI4.2中“启动服务器”选项不显示
- python-3.x - 即使在打开后对关闭的文件进行 I/O 操作
- amazon-web-services - 即使没有达到最大并发数(1000),lambda 也会返回限制错误
- gcc - GCC:找不到 iostream 编译错误
- oracle11g - ORACLE - 连接来自另一个模式的连接的 2 列
- c# - 平铺对象图层位置绘制到错误的位置
- ios - UITableView 上的 JSON 数据