把XML数据转换为Windows事件日志 [英] Putting XML Data into the Windows Event Log

查看:161
本文介绍了把XML数据转换为Windows事件日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能写XML数据转换成Windows事件日志?

How can I write XML data into the Windows Event Log?

我已经注意到,有一种方法将XML到Windows事件日志(而不是仅仅堆砌成的说明)。其效果是,你得到的一般只是你的描述消息在Windows Vista上查看。你可以看到在详细信息查看XML数据。

I have noticed that there is a way to insert XML into the windows event log (and not by just stuffing it into the description). The effect is that you get just your description message in the General view on Windows Vista. You can see your XML data in the Details view.

如果您选择友情单选按钮,它出现在事件数据节点下。如果您选择XML模式,你能看到XML。

If you select the Friendly radio button, it appears under the Event Data node. If you select the XML view, then you get to see the XML.

我认为在 EventLog.WriteEntry()方法RAWDATA字节数组会允许我这样做。我试过XMLWriter的输出塞进它。该放数据到事件日志中,但它被视为二进制而不是XML

I thought that the rawData byte array in the EventLog.WriteEntry() method would allow me to do this. I tried stuffing the output of XMLWriter into it. That put data into the event log, but it is viewed as binary instead of XML.

推荐答案

除非我错了,为了写XML的深红/ Vista的事件日志中,您将创建并注册一个清单,这将使你合适的渠道和事件。然后,你必须使用编译清单中的<一个href="http://blogs.msdn.com/windowssdk/archive/2009/02/03/released-windows-sdk-for-windows-7-and-net-framework-3-5-sp1-beta.aspx"相对=nofollow>消息编译器(mc.exe)在WindowsSDK 。

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

然后,如果你想从C#来登录你要创建一个托管提供商来包装事件日志记录API。这是一个有点困难,因为你将不得不使用的PInvoke得到的API。

Then if you want to log from C# you will want to create a managed provider to wrap the event logging API. This is a little harder because you will have to use PInvoke to get at the API.

有关于如何做到这整个过程这里博客文章

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

这篇关于把XML数据转换为Windows事件日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆