是否可以使用 log4net 中的 EventLogAppender 指定自定义文本任务类别?
如果您查看 Windows 事件查看器,您将看到一些具有任务类别的任务,例如 Gatherer 和 Firing Agent,但如果您使用 log4net 来记录事件,则可以仅在 category
属性中提供一个短整数值。我认为使用 System.Diagnostics 方法记录事件的情况是相同的。
是否有某种方法可以指定字符串/文本类别,或者定义枚举供事件查看器使用?
If you look at the Windows Event Viewer, you'll see some tasks with Task Categories such as Gatherer and Firing Agent, but if you use log4net to log events, you can only provide a short integer value in the category
property. I think it is the same case using System.Diagnostics
method of logging events.
Is there some way of specifying string/text categories, or perhaps defining enums for the event viewer to use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要注册您的类别。我发现这篇文章解释了它是如何工作的(虽然有点过时,但我印象中的信息仍然正确):
http://drdobbs.com/184405714
You need to register your categories. I found this article which explains how this works (though it is a bit dated, I have the impression that the information is still correct):
http://drdobbs.com/184405714
您可以使用字符串文本和标识它们的枚举创建一个 DLL。然后将 DLL 与注册表中的应用程序关联起来。
这里有一个很好的教程:http://www. eventlogblog.com/mt/mt-search.cgi?search=python&IncludeBlogs=1——我最近尝试过,它仍然适用于当前版本的 Platform SDK 和 Visual Studio Express。但是您必须将一些文件夹添加到 VS 为您设置的 PATH 变量中,用于存放可执行文件和 DLL。
You create a DLL with both the string texts and the enums that identify them. Then you associate the DLL with your application in the registry.
There is a good tutorial here: http://www.eventlogblog.com/mt/mt-search.cgi?search=python&IncludeBlogs=1 -- I've tried it recently and it still works for current versions of the Platform SDK and Visual Studio Express. But you will have to add some folders to the PATH variable that VS sets up for you, for the executables and DLLs.