Creating Custom Events and Event IDs for Monitoring with MOM 2005

With our recent implementation of MOM 2005, we are trying to update some of our custom
internal IT applications so that they can be monitored more effectively using MOM.
So in essence, I have been trying to get a web service to log results to the application
event log on the web server.

The first thing I ran into was a permissions issue by trying to create an event source
using the following code:

If Not objEventLog.SourceExists(“EDM
Web Service”
) Then

   objEventLog.CreateEventSource(“EDM
Web Service”
, “Application”)
End If

>

There are two issues. First, you cannot create the event source like this from a web
app. It is documented by Microsoft in this article:

PRB: “Requested
Registry Access Is Not Allowed” Error Message When ASP.NET Application Tries to Write
New EventSource in the EventLog

I worked around this by taking the first step and just manually creating the registry
key for the EDM Web Service since we will not be packaging this app for deployment.
After creating it you will then need to give the local ASPNET account write access
to the application log in the registry as detailed here.

ASP.NET and
the Event Log

Now my last problem was that rule groups in MOM are based on Event IDs. If you pass
an event ID to the write entry method like this:

objEventLog.Source = “EDM
Web Service”


objEventLog.WriteEntry(“”,
EventLogEntryType.Error,
1000)

you will get an error similar to the following when you open the event in the event
log


The description for Event ID ( 1001 ) in Source ( EDM Web Service ) cannot be found.
The local computer may not have the necessary registry information or message DLL
files to display messages from a remote computer. You may be able to use the /AUXSOURCE=
flag to retrieve this description; see Help and Support for details. The following
information is part of the event: .

Well, I want desciptive text in my Event Messages, so the solution is to use a message
dll. The instructions for doing this are included in the link below.

Getting the most out of Event
Viewer

Basically you create a text file that has event id’s corresponding to a message. This
is great for your code as well since it allows you to store descriptions for messages
separately from your code. Now we can set MOM up to generate an alert or change the
state of a server if a critical message pops up.

Random Posts

Loading…

Leave a Reply