Use single Elmah.axd for multiple applications with single DB log

元气小坏坏 提交于 2019-12-03 06:46:12

问题


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?


回答1:


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...




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/1396769/use-single-elmah-axd-for-multiple-applications-with-single-db-log

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!