Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ELMAH applicationName: show exceptions logged by another site

I have one site logging errors using Elmah.SqlErrorLog. My goal to have another site contain the handlers that serve the pages one would typically see at localhost/elmah.axd. The reason for this is that the site logging the errors uses Forms authentication, while I want to restrict who can see the logs by Windows authentication.

The site doing the logging is running on port 80, and the site to display the logs is on port 8008. At first, I was unable to see exceptions from the logging site. Then I found this answer, which explains that you can set the applicationName for your errorLog: Separate viewer application for ELMAH's log

I looked in the table that ELMAH logs to, and found that prior to my attempt to separate logging/viewing into two different sites, it has been logging "/LM/W3SVC/3/ROOT" in the Application column.

After specifying applicationName="/LM/W3SVC/3/ROOT", it worked! Unfortunately, this value varies machine to machine, which will not work nicely when the next guy's dev box happens to have an applicationName of "/LM/W3SVC/10/ROOT". According to this, that string has to do with the local machine namespace: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/44a57859-8fbb-4238-a7b5-f10c34cf8fe8.mspx?mfr=true

How can I get the site on port 8008 that is for viewing the logs to display exceptions logged from the site on port 80?

like image 794
BenWillkommen Avatar asked Sep 22 '12 00:09

BenWillkommen


1 Answers

Once you have set the applicationName explicitly, this is the name it should be using when it records the exception to the database.

If you set applicationName="Foo" in the config for both sites, any new exceptions recorded on the site on port 80 should be visible to the site on port 8008

If you need to make old errors visible that were recorded prior to this change, you could update the Application field in the ELMAH_Error table to be 'Foo' as well

EDIT

The applicationName value is set as an attribute on the errorLog element in the web.config

    <elmah>
        <security allowRemoteAccess="false" />
        <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="elmah-sqlserver" applicationName="Foo" />
    </elmah>
like image 192
dave clements Avatar answered Nov 01 '22 23:11

dave clements