Is it permissible to write to the application event source?

There are certain circumstances in our application in which non-fatal errors occur and the application is restored.

An example of this is the incorrect definition of some imported items when populating the specified items in the selection list. Errors will not cause the application to crash, but the user will be warned that some of the items failed to load.

In this case, the error is logged in the application event log as a warning. This is a non-fatal error that the application recovers, but entering the event log allows us to see the original error, if necessary.

Our problem is that the software must be installed with a Power User account. Not being an administrator account, we will not be able to create our own event sources for the application.

The goal is to record errors instead of the source of the Application event (which already exists in the application event log). However, this leads to the inclusion of text similar to the following.

Description for event id 0 from source application could not be found. Either the component that raises this event is not installed on your local computer, or the installation is corrupted. You can install or repair the component on the local computer.

This is because EventID is 0 when we write it. This approach will be implemented, but is there a better way? Is there a non-administration way to specify an EventID for the application event source to indicate that it came from our application?

+7
source share
2 answers

The error you see as a description for event ID 0 from the source Application could not be found. Either the component that raises this event is not installed on your local computer, or the installation is corrupted. You can install or repair the component on the local computer. is the result of the message file of the registered application file having no entry for event identifier 0. The message that you see is the result of obtaining a template for the message identifier from the event message file and formatting it with the event payload.

I would not recommend that you capture a source that you do not have. Those who consume these events have specific expectations as to what they mean and what information they carry.

Relatively Is there a way that the admin is not to specify the EventID for the application event source to indicate that it came from our application? What do you expect from this event identifier specification? A source is what determines where an event came from.

EDIT:

You will receive an error message in the event viewer, regardless of whether you specify an event identifier other than 0 because this source does not have a registered event message file. And even if this is the case, you will either have to use event identifiers that have an entry in the message file (confuse event consumers), and event identifiers that do not have an entry and still receive an error.

0
source

You can pass the application event identifier as a parameter: (example: 234)

EventLog.WriteEntry("Application", "your log message here", EventLogEntryType.Warning, 234); 

Further reading in EventLog.WriteEntry Method

http://msdn.microsoft.com/en-us/library/xzwc042w.aspx

0
source

All Articles