Reputation:
I want to add an event message with a Critical type to Windows Event Log using ReportEvent()
, but according to the documentation, only the below types are permitted:
EVENTLOG_SUCCESS
EVENTLOG_ERROR_TYPE
EVENTLOG_WARNING_TYPE
EVENTLOG_INFORMATION_TYPE
EVENTLOG_AUDIT_SUCCESS
EVENTLOG_AUDIT_FAILURE
So how do I add EVENTLOG_CRITICAL
? As Critical messages can be seen in the Windows Event Viewer.
Upvotes: 1
Views: 563
Reputation: 595712
As the ReportEvent()
documentation says, it does not support "critical" messages. There is nothing you can do or add to change that.
However, ReportEvent()
is not the only way, or even the preferred way, to log messages to the Windows Event Log. MSDN states the following in the documentation for the Event Logging API (which ReportEvent()
is part of):
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.
In the documentation for the newer Event Log API, the section on Writing an Instrumentation Manifest has a sub-section about Defining Severity Levels, which shows Win:Critical
is one of the "commonly used severity levels".
You will have to replace your existing call to ReportEvent()
to use one of the Event Tracing Functions instead (EventWrite()
, EventWriteEx()
, EventWriteString()
, TraceEvent()
, etc).
Upvotes: 1