26

We have a single SQL Log for storing errors from multiple applications. We have disabled the elmah.axd page for each one of our applications and would like to have a new application that specifically displays errors from all of the apps that report errors to the common SQL log.

As of now, even though the application for all errors is using the common SQL log, it only displays errors from the current application. Has anyone done this before? What within the elmah code might need to be tweaked?

RSolberg
  • 26,821
  • 23
  • 116
  • 160
  • 2
    Thanks for asking such a nice question in clear manner, you have taken my words with Time machine. It is almost 6-7 years later now. – AKS Dec 14 '15 at 07:26

3 Answers3

33

I assume by "SQL Log" you mean MSSQL Server... If so, probably the easiest way of accomplishing what you want would be to edit the stored procedures created in the SQL Server database that holds your errors.

To get the error list, the ELMAH dll calls the ELMAH_GetErrorsXML proc with the application name as a parameter, then the proc filters the return with a WHERE [Application] = @Application clause.

Just remove the WHERE clause from the ELMAH_GetErrorsXML proc, and all errors should be returned regardless of application.

To get a single error record properly, you'll have to do the same with the ELMAH_GetErrorXML proc, as it also filters by application.

This, of course, will affect any application retrieving errors out of this particular database, but I assume in your case you'll only ever have the one, so this should be good.

CAVEAT: I have not tried this, so I can't guarantee the results...

Eric King
  • 11,594
  • 5
  • 43
  • 53
4

It's not a problem to override the default Elmah handler factory so that it will filter Elmah logs by applications. I wrote a sample app that shows how to do it with MySql: http://diagnettoolkit.codeplex.com/releases/view/103931. You may as well check a post on my blog where I explain how it works.

Sebastian
  • 3,764
  • 21
  • 28
  • +1 - this is how this is supposed to be done. Clean and simple and no need to modify either the original DDL scripts nor the Elmah source code. The blog post explains it all. Good job sir! – Lasse Christiansen Sep 06 '14 at 15:26
  • This is a nice alternative. However, the downside is that you can still only see errors from one application at a time, and you have to know the name of the application up front. If you want to see a list of errors across all applications (which is how I interpreted the question), this won't do it, unless I am just not seeing that piece. – Eric King Mar 05 '15 at 14:55
2

Yes, it easily works. However you can't see app name in Elmah/Default.aspx. I haven't found if it is confugurable - just display one column more.

  • 1
    That's true. The layout for that page is defined in the ErrorLogPage.cs code, so to add another column you would have to download the source, make the changes, and recompile. http://code.google.com/p/elmah/source/browse/trunk/src/Elmah/ErrorLogPage.cs – Eric King Dec 10 '09 at 00:30