问题描述
我使用将Elmah.MVC安装到我的MVC项目中。它在开发环境中可以正常工作,但是当我将网站上传到托管服务器(IIS7)时,它不会记录错误。
I installed Elmah.MVC to my MVC project using Elmah.MVC Nuget package. It works fine in development environment, but when I upload website to hosting server (IIS7) it does not log errors.
这是我的Web配置文件(仅Elmah配置),
This is my web config file (only the 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>
有人可以检查&告诉它为什么在托管环境中不记录错误?
Can someone please check & tell why it is not logging errors in Hosting environment?
推荐答案
您的应用程序是否对生产环境中的App_Data目录具有写权限?
Does your application have write access to the App_Data directory in your production environment?
根据您的配置,您没有登录到SQL->应用程序池标识将需要能够修改/写入文件才能追加到App_Data /Elmah.Errors文件。
Based on your configuration, you are not logging to SQL -> the application pool identity will need to be able to modify/write to files in order to append to the App_Data/Elmah.Errors file. More information on the why and how.
这篇关于Elmah.MVC不会在生产环境中记录错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!