Entering XML data into the Windows event log

How can I write XML data to a Windows event log?

I noticed that there is a way to insert XML into the Windows event log (and not just populate it with a description). The effect is that you only get your description in the view Generalin Windows Vista. You can see your XML data in a view Details.

If you select the switch Friendly, it will appear under the Event Datanode. If you select an XML view, you will see XML.

I thought that the rawData byte array in the method EventLog.WriteEntry()would allow me to do this. I tried to add the XMLWriter result to it. This puts the data in the event log, but is considered binary, not XML.

+3
source share
3 answers

If I am wrong to write xml to the Crimson / Vista event log, you will create and register a manifest that will give you the appropriate channels and events. Then you need to compile the manifest using the Message Compiler (mc.exe) in the WindowsSDK .

Then, if you want to register in C #, you will want to create a managed provider to port the event registration API. This is a little trickier because you will need to use PInvoke to access the API.

There are blog posts on how to do the whole process here .

+3
source

Windows SDK ( 6.1), EventProvider.
# ( Vista ), API (AKA ).
, ( ).

+2

For .Net 4.5 Look at the new EventSource, it also supports automatic manifest creation.

+2
source

Source: https://habr.com/ru/post/1707796/


All Articles