写入事件查看器C#时的源名称 [英] Source name when writing to event viewer C#
问题描述
以C#语言写入事件查看器时如何更改源名称?
How do you change the source name when writing to the event viewer in C# language?
当前拥有这个
string cs =应用程序";
string cs = "Application";
if (!EventLog.SourceExists(cs))
EventLog.CreateEventSource(cs, "ReceiveDaily");
EventLog.WriteEntry(cs, message.Message, EventLogEntryType.Error);
如果将CS更改为其他设置,我会在事件查看器中看到一个Security-Kerberos(0x7)弹出窗口 但是,当我放置应用程序"时,它将错误记录在错误日志中.但是随后的来源是应用程序",这并不是一个很好的描述……
If I change CS to anything else, I see a Security-Kerberos (0x7) popping up at my event viewer It writes the error in the errorlog when I put "Application" though. But then the source is "Application", which isn't a very good description from where it comes ...
谢谢.
推荐答案
正如@Phil所述,除非您以管理员模式运行,否则我认为您不能动态创建事件源.
As @Phil mentions, I don't think that you can dynamically create event sources unless you are running in admin mode.
但是,如果您知道应用程序需要的一组源,则可以使用System.Diagnostics.EventLogInstaller
和InstallUtil.exe
预先安装它们.然后,这些源将可供您的应用程序使用.
However, if you know the set of sources that your application needs, then you can pre-install them using a System.Diagnostics.EventLogInstaller
and InstallUtil.exe
. These sources will then be available to use by your application.
这篇关于写入事件查看器C#时的源名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!