配置ELMAH 记录ASP.NET 应用程序错误
背景
使用ELMAH可以尽通过修改配置文件记录ASP.NET 应用程序中未处理的错误。
环境
ELMAH-1.2-sp2
VS2008
Win7 IIS
步骤
1 添加引用 Elmah.dll
2 配置Web.Config configSections
<sectionGroup name="elmah"> <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" /> </sectionGroup>
3 Web.Config 添加如下节
<elmah> <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ConnectionString" /> </elmah>
4 配置 System.Web 下 httpModules如下
<httpModules> <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" /> </httpModules>
5 配置 System.Web 下 httpHandlers如下
<httpHandlers> <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" /> </httpHandlers>
6 配置 system.webServer 下 modules 节
<modules> <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" /> </modules>
7 配置 system.webServer 下 handlers节
<handlers> <add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" /> </handlers>
8 执行SQL数据库脚本 ELMAH-1.2-db-SQLServer.sql
配置完成
最终效果如下


浙公网安备 33010602011771号