The table ELMAH_Error distinguishes the source of error in the columns Host (storing the host name of the web application) and Application (storing the IIS Configuration Path of the web application, for explanations see e.g. here).
By default, the /elmah handler only displays the error messages of the current application.
However, I wanted to see the errors of all ELMAH-enabled applications.
After some research into the C# code and the MSSQL database, the solution is surprisingly simply:
- Create a new database, e.g. “elmah-read”
- Create synonyms to the original table and the logging SP (we won’t really need this SP)
CREATE SYNONYM ELMAH_Error FOR Elmah.dbo.ELMAH_Error GO
CREATE SYNONYM ELMAH_LogError FOR Elmah.dbo.ELMAH_LogError GO
- Copy the stored procedure [dbo].[ELMAH_GetErrorXml] and remove the @Application from the WHERE clause
WHERE [ErrorId] = @ErrorId --AND [Application] = @Application
- Copy the stored procedure [dbo].[ELMAH_GetErrorsXml], removing the @Application from the WHERE clauses, and extending the selected [host] column
SELECT errorId = [ErrorId], application = [Application], host = [Host] + ' ' + RIGHT( [Application], CHARINDEX( '/', REVERSE( [Application] ) + '/' ) - 1 ),
- Create an empty ASP.Net Web Application in VS, add Elmah Core Library and Elmah.Mvc from NuGet, and configure the connection string as in the original web applications
- To allow remote access to the log viewer, add in web.config:
<elmah> <security allowRemoteAccess="true"/> </elmah>
- Don’t forget to properly configure the Authentication feature of the log viewer application in IIS