4

Simple set up, I'm using ELMAH to log exceptions and send me e-mails. Everything works fine on my local machine, but when I put the changes on my production server, errors don't get logged and I don't get e-mails.

Here's my web.config on my local machine:

<?xml version="1.0"?>
<configuration>
    <configSections>
        <sectionGroup name="elmah">
            <section name="security" requirePermission="false"
                type="Elmah.SecuritySectionHandler, Elmah" />
            <section name="errorLog" requirePermission="false"
                type="Elmah.ErrorLogSectionHandler, Elmah" />
            <section name="errorMail" requirePermission="false"
                type="Elmah.ErrorMailSectionHandler, Elmah" />
            <section name="errorFilter" requirePermission="false"
                type="Elmah.ErrorFilterSectionHandler, Elmah" />
        </sectionGroup>
    </configSections>

    <elmah>
        <security allowRemoteAccess="0" />
        <errorLog type="Elmah.SqlErrorLog, Elmah"
            connectionStringName="MyDB" />
        <errorMail from="errors@mysite.com" to="myemail@mysite.com"
            subject="Error" smtpServer="localhost" smtpPort="25" 
            userName="user@mysite.com" password="mypassword" />
    </elmah>

    <connectionStrings>
        <add name="MyDB" connectionString="Data Source=.\SQLEXPRESS
            AttachDbFilename=|DataDirectory|\MyDB.mdf;
            Integrated Security=True;User Instance=True;
            MultipleActiveResultSets=True"
            providerName="System.Data.SqlClient" />
        <!--<add name="MyDB" connectionString="Server=mysite.com;
            Database=MyDB;User ID=user;Password=mypassword;
            Trusted_Connection=True;Integrated Security=False;
            MultipleActiveResultSets=True"
            providerName="System.Data.SqlClient" />-->
    </connectionStrings>

    <system.web>  
        <!--<httpHandlers>
            <add verb="POST,GET,HEAD" path="elmah.axd" 
                type="Elmah.ErrorLogPageFactory, Elmah" />
        </httpHandlers>-->
        <httpModules>
            <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
            <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
            <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
        </httpModules>
    </system.web>

    <location path="Admin/Errors">
        <system.web>
            <httpHandlers>
                <add verb="POST,GET,HEAD" path="elmah.axd"
                    type="Elmah.ErrorLogPageFactory, Elmah" />
            </httpHandlers>
        </system.web>
    </location>
</configuration>

The only difference between the web.config on my machine and on production is the connection string being used. On my machine, I'm connecting to a .mdf file. On production, I'm connecting to an external database.

Can anyone see what I'm doing wrong here?

I'm using C# and ASP.NET MVC 3

Steven
  • 18,761
  • 70
  • 194
  • 296
  • What version of IIS is your production server running? – NotMe Aug 15 '11 at 19:16
  • This comment is for somebody else that might be having the same issue. Don't forget to have the 3 stored procedures created on the production server as well. (ELMAH_GetErrorsXml, ELMAH_GetErrorXml and ELMAH_LogError and that the access is provided for the DB user). Hope this helps someone. – ProgrammerV5 Nov 17 '16 at 14:39

1 Answers1

9

You need to set allowRemoteAccess ="yes" for remote access.

  <elmah>
    <security allowRemoteAccess="yes"/>
  </elmah>

And check the elmah admin page to see if that helps you.

Example access: http://prodserver/elmah.axd

Michael D. Irizarry
  • 6,186
  • 5
  • 30
  • 35
  • Hmmm, well there seems to be a problem, even the elmah.axd page won't load on production, I get a 404 error. But it does work on my local machine. Any reason that would be happening? – Steven Aug 15 '11 at 19:38
  • 404 is Not Found, which means that it is not a permissions issue, but a configuration/install issue. Is elmah installed on the server? – Philipp Schmid Aug 15 '11 at 19:40
  • @Philipp - Yes, I have the .dll on the server. – Steven Aug 15 '11 at 19:43
  • Have you checked the EventViewer? might give you another hint. – Michael D. Irizarry Aug 15 '11 at 19:52
  • I wish I could have 2 accepted answers, because yours helped as well. But Andy's helped me with the bigger overall issue. – Steven Aug 15 '11 at 20:59