gpt4 book ai didi

c++ - 我需要添加一个关键类型的事件日志

转载 作者:行者123 更新时间:2023-11-30 05:13:22 29 4
gpt4 key购买 nike

我想使用 ReportEvent() 向 Windows 事件日志添加一个类型为Critical 的事件消息, 但根据文档,只允许以下类型:

EVENTLOG_SUCCESS  
EVENTLOG_ERROR_TYPE
EVENTLOG_WARNING_TYPE
EVENTLOG_INFORMATION_TYPE
EVENTLOG_AUDIT_SUCCESS
EVENTLOG_AUDIT_FAILURE

那么如何添加 EVENTLOG_CRITICAL?在 Windows 事件查看器中可以看到关键消息。

最佳答案

正如 ReportEvent() 文档所说,它不支持“关键”消息。您无法执行或添加任何内容来更改它。

但是,ReportEvent() 并不是将消息记录到 Windows 事件日志的唯一方式,甚至不是首选方式。 MSDN 在 Event Logging API 的文档中声明了以下内容(ReportEvent() 是其中的一部分):

Note The Event Logging API was designed for applications that run on the Windows Server 2003, Windows XP, or Windows 2000 operating system. In Windows Vista, the event logging infrastructure was redesigned. Applications that are designed to run on Windows Vista or later operating systems should use Windows Event Log to log events.

在较新的文档中 Event Log API , 关于 Writing an Instrumentation Manifest 的部分有一个关于 Defining Severity Levels 的小节,这表明 Win:Critical 是“常用严重性级别”之一。

您必须替换对 ReportEvent() 的现有调用才能使用 Event Tracing Functions 之一相反( EventWrite()EventWriteEx()EventWriteString()TraceEvent() 等)。

关于c++ - 我需要添加一个关键类型的事件日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43973493/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com