对于我的MVC4应用程序,我使用NUGET将ELMAH加载到我的应用程序中。 但是在web.config中我收到以下错误消息:
位置元素未使用;在elmah.axd找不到任何项目项目。
我打算用这个名字创建一个文件吗? 我该如何解决这个问题?
<location path="elmah.axd" inheritInChildApplications="false">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for
more information on using ASP.NET authorization securing ELMAH.
<authorization>
<allow roles="admin" />
<deny users="*" />
</authorization>
</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>
答案 0 :(得分:4)
如果您使用Elmah.MVC.dll,则无需为elmah.axd添加处理程序。 Elmah.MVC.dll包含一个控制器,使您可以在http://www.yourwebsite.com/elmah访问日志。完整地描述了这一点:
https://github.com/alexanderbeletsky/elmah.mvc
我推荐这种方法,因为配置比elmah.axd处理程序更简单。
答案 1 :(得分:0)
您需要在RegisterRoutes中添加以下内容:
routes.IgnoreRoute( “elmah.axd / {*} PATHINFO”);
答案 2 :(得分:0)
我通过NuGet安装了Elmah.MVC。
大多数web.config设置都是由安装自动添加的。
不得不补充:
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
和
<handlers>
<add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</handlers>
然后在配置的最底部会有一个空部分,所以我将其修改为:
<elmah>
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>
并记录到XML文件工作!
注意,如果不适合,您可能需要调整logPath。
吉娜! VS2012,MVC4,所有更新/ sp应用