下面是这文章,使用ELMAH将错误记录到XML文件中。我将elmah.dll添加到web应用程序的bin中,并修改了web配置,如下所示。但是我没有在App_Data文件夹中找到任何xml文件。
Web
<configSections>
<sectionGroup name="elmah">
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
</sectionGroup>
</configSections>
<elmah>
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<customErrors mode="On" defaultRedirect="Error.html"> </customErrors>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
</httpModules>
<httpRuntime/>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>注意:为避免添加了 validateIntegratedModeConfiguration,检测到了不适用于集成托管管道模式错误的ASP.NET设置
代码在中的应用
protected void Page_Load(object sender, EventArgs e)
{
throw new InvalidCastException();
}此外,我还可以使用http://localhost/Elmah.Articel.web/elmah.axd找到日志。所以我尝试了http://localhost:61276/elmah.axd,但是它抛出了404个错误。
发布于 2015-05-29 11:59:31
试一试,我用这个方法,
<elmah>
<security allowRemoteAccess="false" />
</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>https://stackoverflow.com/questions/30528958
复制相似问题