2012-07-27 47 views
2

我使用Elmah.MVC Nuget package將Elmah.MVC安裝到我的MVC項目中。它在開發環境中工作正常,但是當我將網站上載到託管服務器(IIS7)時,它不會記錄錯誤。Elmah.MVC不會在生產環境中記錄錯誤

這是我的網絡配置文件(僅ELMAH configuraion),

<?xml version="1.0" encoding="utf-8"?> 
<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> 
    <connectionStrings> 
    ... 
    </connectionStrings> 
    <appSettings> 
     <add key="webpages:Version" value="1.0.0.0" /> 
     <add key="ClientValidationEnabled" value="true" /> 
     <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
     <add key="elmah.mvc.disableHandler" value="false" /> 
     <add key="elmah.mvc.requiresAuthentication" value="false" /> 
     <add key="elmah.mvc.allowedRoles" value="*" /> 
    </appSettings> 

    <system.web> 
     <customErrors mode="Off"> 
     </customErrors> 
     ... 
     <httpModules> 
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" /> 
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /> 
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" /> 
     </httpModules> 
    </system.web> 
    <system.webServer> 
     <validation validateIntegratedModeConfiguration="false" /> 
     <modules runAllManagedModulesForAllRequests="true"> 
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" /> 
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" /> 
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" /> 
     </modules> 
     ... 
    </system.webServer> 
    ... 
    <elmah> 
     <security allowRemoteAccess="yes" /> 
     <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/Elmah.Errors" /> 
    </elmah> 
    <location path="elmah.axd" inheritInChildApplications="false"> 
     <system.web> 
      <httpHandlers> 
       <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" /> 
      </httpHandlers> 

     </system.web> 
     <system.webServer> 
      <handlers> 
       <add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" /> 
      </handlers> 
     </system.webServer> 
    </location> 
</configuration> 

可有人請&知道爲什麼它不是在託管環境中記錄錯誤?

+0

可能重複[ELMAH不記錄](http://stackoverflow.com/questions/3194700/elmah-is-not-logging) – 2014-01-07 07:09:02

回答

6

您的應用程序是否具有對生產環境中的App_Data目錄的寫入權限?

根據您的配置,您未記錄到SQL - >應用程序池標識需要能夠修改/寫入文件以附加到App_Data/Elmah.Errors文件。 More information on the why and how.

+0

非常感謝你... :)文件夾權限是問題所在。 .. – Nalaka526 2012-07-27 06:24:20

3

我有類似的問題。我在用這條線:

<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~\App_Data\Elmah.Errors" /> 

錯了。你必須使用斜槓:

<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/Elmah.Errors" /> 

這應該是一個評論,但我沒有足夠的代表。

相關問題