8

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?

Community
  • 1
  • 1
BenWillkommen
  • 1,472
  • 13
  • 21

1 Answers1

14

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>
dave clements
  • 1,505
  • 2
  • 13
  • 28
  • I assume you mean set applicationName in the web.config. Where should this go? The google results I'm seeing all relate to the section. Is this correct? http://weblogs.asp.net/scottgu/archive/2006/04/22/Always-set-the-_2200_applicationName_2200_-property-when-configuring-ASP.NET-2.0-Membership-and-other-Providers.aspx – BenWillkommen Sep 24 '12 at 15:14
  • 1
    I've updated the answer to include an example - you should have an elmah section in your web.config - the applicationName gets set on the errorLog section within that – dave clements Sep 24 '12 at 23:09