>>
I have a custom error page that uses the ID of the log entry and it
seams like that event would be the best place to get that info without
having to modify the ELMAH source.
<<
Yes, the Logged event is really designed to support such a scenario.
> Does anyone have any sample code on how to attach to the
> ErrorLogModule.Logged event?
To tap into it, you need to add an event handler in the Global.asax or its code-behind. The event handler needs to look like this in C#:
void MMM_Logged(object sender, ErrorLoggedEventArgs e) {
// ...
}
For example:
void MMM_Logged(object sender, ErrorLoggedEventArgs e) {
Debug.WriteLine(string.Format("{0} = {1}",
e.Entry.Id, e.Entry.Error.Message));
}
The "MMM" in the name of the event handler above needs to be replaced with the name you gave to the module entry (under httpModules) in web.config. Say you named it ErrorLog, like this:
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
Then you'll need to name the event handler ErrorLog_Logged. This is the convention for handling events from any
ASP.NET module (that is, configured module name + event name).
Hope this helps,
- Atif