写入Windows应用程序事件日志中没有注册的事件源

编程入门 行业动态 更新时间:2024-10-24 22:29:18
本文介绍了写入Windows应用程序事件日志中没有注册的事件源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有办法写入此事件日志:

Is there a way to write to this event log:

或者至少,其他一些Windows默认的日志,在那里我没有注册事件源?

Or at least, some other Windows default log, where I don't have to register an event source?

推荐答案

确实是这样,它存在的方式写信给你要找的事件日志。所以,你不需要创建一个新的来源,只是简单地使用存在的,它往往具有相同的名称作为事件日志的名字,并在某些情况下,如事件日志应用程序,可以入店没有管理权限* 。

Yes indeed, it exists a way to write to the eventlog you were looking for. So, you don't need to create a new source, just simply use the existent, which often has the same name as the EventLog's name and also, in some cases like the event log "Application", can be accesible without administrative privileges*.

*其他情况下,如果你不能直接访问它,是安全日志为例,它仅由操作系统访问。

*Other cases, where you cannot access it directly, are the Security EventLog for example, which is only accessed by the operating system.

我用这个code直接写入到应用程序事件日志:

I used this code to write directly to the "Application" event log:

using(EventLog eventLog = new EventLog("Application")) { eventLog.Source = "Application"; eventLog.WriteEntry("Log message example", EventLogEntryType.Information, 101, 1); }

正如你所看到的,事件日志的源名称是一样的EvenLog本身。这样做的原因可以在该链路中找到(Ⅰ粗体其指源名的部分):

As you can see, the EventLog's source name is the same as the EvenLog itself. The reason of this can be found in this link (I bolded the part which refers to source name):

msdn.microsoft/en-us/library/windows/desktop/aa363661(v=vs.85).aspx

每个日志中的事件日志项包含子项叫做事件源。事件源是记录该事件的软件的名称。 这通常是应用程序或应用程序的子组件,如果应用程序是大名的名称。您最多16,384事件源可以添加到注册表中。

Each log in the Eventlog key contains subkeys called event sources. The event source is the name of the software that logs the event. It is often the name of the application or the name of a subcomponent of the application if the application is large. You can add a maximum of 16,384 event sources to the registry.

它回答你的问题。

更多推荐

写入Windows应用程序事件日志中没有注册的事件源

本文发布于:2023-11-11 07:56:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577817.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:事件   没有注册   应用程序   日志   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!