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
Are you running IIS7 in production? Read my answer to a similar question here Elmah, convert to .Net4 vs2010, run on server 2008, does not work
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
来源:https://stackoverflow.com/questions/7069495/elmah-works-on-local-machine-but-not-on-production