简体   繁体   English

“无法找到源Y中事件ID X的描述。”

[英]“The description for Event ID X in Source Y cannot be found.”

I'm trying to write custom events from my web application to the windows event log. 我正在尝试将自定义事件从我的Web应用程序写入Windows事件日志。 I've had no luck getting the message strings to work, I keep getting "The description for Event ID X in Source Y cannot be found." 我没有运气使消息字符串工作,我一直得到“无法找到源Y中的事件ID X的描述。”

In trying to narrow this down I decided to write out an event to a source that already exists on my machine. 在尝试缩小范围时,我决定将事件写入我的机器上已存在的源。 I just looked at one of the events that was already written out, specifically SceCli event 1704. 我只看了一个已经写出来的事件,特别是SceCli事件1704。

I execute the following code: 我执行以下代码:

var log = new EventLog("Application");
log.Source = "SceCli";

var ev = new EventInstance(1704, 0, EventLogEntryType.Information);
log.WriteEvent(ev);

However, this still gives me the following in Event Viewer: 但是,这仍然在事件查看器中提供以下内容:

The description for Event ID ( 1704 ) in Source ( SceCli ) cannot be found. 无法找到源(SceCli)中的事件ID(1704)的描述。 The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. 本地计算机可能没有必要的注册表信息或消息DLL文件来显示来自远程计算机的消息。 You may be able to use the /AUXSOURCE= flag to retrieve this description; 您可以使用/ AUXSOURCE =标志来检索此描述; see Help and Support for details. 请参阅帮助和支持以获取详细信 The following information is part of the event: The event log file is corrupt.. 以下信息是事件的一部分:事件日志文件已损坏。

I'm not sure what I'm missing here. 我不确定我在这里缺少什么。 I'm writing out the exact same event that already exists, and it still can't find the message string. 我正在写出已经存在的完全相同的事件,但它仍然无法找到消息字符串。

I also faced similar problem. 我也遇到过类似的问题。 After doing lot of research I did following I verified the steps according to this article http://www.codeproject.com/Articles/4166/Using-MC-exe-message-resources-and-the-NT-event-lo Everything seemed to be in place. 在做了大量的研究后,我做了以下我根据这篇文章验证了步骤http://www.codeproject.com/Articles/4166/Using-MC-exe-message-resources-and-the-NT-event-lo Everything好像到位了。 Except one thing..i realised it when I stumbled on this msdn http://msdn.microsoft.com/en-us/library/windows/desktop/aa363661(v=vs.85).aspx 除了一件事......当我偶然发现这个msdn时,我意识到了这一点http://msdn.microsoft.com/en-us/library/windows/desktop/aa363661(v=vs.85).aspx

As last paragraph says.. 'If the application calls RegisterEventSource and passes a source name that cannot be found in the registry, the event-logging service uses the Application log by default. 如上一段所述..'如果应用程序调用RegisterEventSource并传递在注册表中找不到的源名称,则事件日志记录服务默认使用应用程序日志。 However, because there are no message files, the Event Viewer cannot map any event identifiers or event categories to a description string, and will display an error. 但是,由于没有消息文件,因此事件查看器无法将任何事件标识符或事件类别映射到描述字符串,并且将显示错误。 For this reason, you should add a unique event source to the registry for your application and specify a message file.' 因此,您应该为应用程序的注册表添加一个唯一的事件源,并指定一个消息文件。 So my application name in RegisterEventSource was not matching with the application name in registry. 因此,我在RegisterEventSource中的应用程序名称与注册表中的应用程序名称不匹配。 I fixed this and now it works... So please double check your registry entries if you face this problem. 我修复此问题,现在它可以工作......所以如果您遇到此问题,请仔细检查您的注册表项。

Can you see the other events properly? 你能正确看到其他事件吗? Most probably you are unable to use that particular source and event id (SceCli/1704) because the C# event class does not provide the right number of parameters to match the event template in the event message file. 很可能您无法使用该特定源和事件ID(SceCli / 1704),因为C#事件类不提供与事件消息文件中的事件模板匹配的正确数量的参数。 I think it will only work with sources that have just "%1" in their event message file (see http://www.eventid.net/show-DocId-22.htm for more details about that). 我认为它只适用于事件消息文件中只有“%1”的源(有关详细信息,请参阅http://www.eventid.net/show-DocId-22.htm )。

Anyway, I think you need to create a source for your custom application (if it doesn't exist) and then record the log entry. 无论如何,我认为您需要为自定义应用程序创建一个源(如果它不存在),然后记录日志条目。 Before recording an event check if the source exists and create it if it doesn't: 在记录事件之前检查源是否存在,如果不存在则创建它:

if (!EventLog.SourceExists("MyWebApp"))
         EventLog.CreateEventSource("MyWebApp", "Application");
EventLog.WriteEntry("MyWebApp", "Some message", EventLogEntryType.Information, 1704);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到源“y”中事件 ID“x”的描述。 从 eventvwr C# 读取“系统”事件日志 - The description for Event ID 'x' in Source 'y' cannot be found. Reading 'System' event logs from eventvwr C# 从Windows 8.1写入EventLog时,显示消息“找不到源中事件ID 0的描述。” - Writing to EventLog from Windows 8.1, message saying “The description for Event ID 0 from source cannot be found.” 找不到源“Microsoft-Windows-Kernel-Power”中事件 ID“X”的描述 - The description for Event ID 'X' in Source 'Microsoft-Windows-Kernel-Power' cannot be found ASP.Net Core 1记录错误 - 无法找到源应用程序中事件ID xxxx的描述 - ASP.Net Core 1 Logging Error - The description for Event ID xxxx from source Application cannot be found “Y”中的实体参与“FK_Y_X”关系。 找到 0 个相关的“X”。 1 'X' 预期 - Entities in 'Y' participate in the 'FK_Y_X' relationship. 0 related 'X' were found. 1 'X' is expected 找不到名为ID的列。 参数名称:columnName - Column named ID cannot be found. Parameter name: columnName 找不到视图。 - View Cannot be Found. X中的实体参与Y关系。 找到0个相关目标。 预期目标1 - Entities in X participate in the Y relationship. 0 related Target were found. 1 Target is expected Serilog Event Sink Description for even XXX can be found 错误 - Serilog Event Sink Description for even XXX cannot be found error 无法在WPF中打开Windows搜索窗格:找不到元素。 (来自HRESULT的异常:0x80070490) - Cannot open the Windows Search Pane in WPF: Element not found. (Exception from HRESULT: 0x80070490)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM