我的网络应用程序根目录上方有一个虚拟目录,用于存储产品图像.
安装ELMAH进行日志记录后,我意识到图像停止工作.这是因为ELMAH在productimages/bin文件夹下查找它的dll.
在我创建了一个bin目录后放置了dll图像现在正在工作
我不认为这是一个长期的解决方案.知道为什么这样做以及如何解决?
我完全按照示例应用程序设置了ELMAH.我试图通过使用以下方法抛出错误来测试ELMAH:
throw new InvalidOperationException();
Run Code Online (Sandbox Code Playgroud)
不幸的是,我的应用程序直接导致错误,ELMAH没有捕获/记录错误.我使用的是ASP.NET 3.5.我不确定我做错了什么,因为Web.Config与示例完全相同
我在Elmah中启用了错误日志过滤,并希望在ErrorLog_Filtering事件处理程序中以编程方式执行此操作.它在Visual Studio开发服务器下运行良好,但是一旦我进入IIS7(我的开发机器本地或我的Web服务器上的远程),就不会调用处理程序(错误日志记录工作正常).
这是我通常的web.config:
<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" />
<section name="errorTweet" requirePermission="false" type="Elmah.ErrorTweetSectionHandler, Elmah" />
</sectionGroup>
</configSections>
<elmah>
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ShopMvcConnectionString" />
</elmah>
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="Elmah.ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="Elmah.ErrorFilter" type="Elmah.ErrorFilterModule" …Run Code Online (Sandbox Code Playgroud) 我有一个问题,我在Global.asax中捕获异常被抛出.作为此异常处理的一部分,由于此异常,我将用户重定向到特定页面.
我也插入了电子邮件模块的ELMAH错误处理.我不想收到此例外的电子邮件.我也不想在ELMAHs忽略列表中添加这种类型的异常,以防我想要围绕异常进行粒度工作(即,只有当它匹配某些属性时,才会在某些页面上发生)
我想要:
Application_OnError一个用户重定向到一个页面(我知道如何做这个部分,更多的程序,我把它留在这里)Application_OnError我抓住它之后停止ELMAH接收此错误我目前正在调用Server.ClearError()我的App_OnError方法,但仍然收到这些电子邮件.
我开始使用ELMAH,我觉得它很棒.我在线阅读了一些文档,但现在我的应用程序没有角色/用户授权设置.
我希望能够通过访问/elmah.axd来阅读生产中的错误日志,但我不想只向所有人开放,elmah是否有任何允许我创建密码的功能(在网络中).配置)并通过查询字符串传递它?模仿"安全"RSS源.或类似的事情....
我在编写查询时遇到问题,这样我就可以在Elmah_Error表中查询AllXml列的内容.
如何列出所有项目节点作为查询的输出.我怎么能只查询某些项目节点的查询?
我想得到以下结果集:
项目价值
===== =====
ALL_HTTP HTTP_CONNECTION:xxxx
ALL_RAW连接:xxxxx
我还希望能够通过ErrorID过滤查询
AllXml列的内容可能如下所示.
<error
application="/"
message="hello world"
source="TestWebElmah"
detail="xxxxx">
<serverVariables>
<item
name="ALL_HTTP">
<value
string="HTTP_CONNECTION:xxxx" />
</item>
<item
name="ALL_RAW">
<value
string="Connection: xxxxx" />
</item>
</serverVariables>
</error>
Run Code Online (Sandbox Code Playgroud) 我使用Elmah.MVC Nuget包将Elmah.MVC安装到我的MVC项目中.它在开发环境中工作正常,但是当我将网站上传到托管服务器(IIS7)时,它不会记录错误.
这是我的网络配置文件(只有Elmah配置),
<?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" …Run Code Online (Sandbox Code Playgroud) 我在web.config中有以下内容:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<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>
<elmah>
<security allowRemoteAccess="yes" />
<errorLog type="Elmah.SqlErrorLog, Elmah"
connectionStringName="PhumafConnectionString" />
<errorMail
from="*******" …Run Code Online (Sandbox Code Playgroud) 我需要记录ApiController中的异常.
安装Elmah.MVC后,我可以在DB中记录404错误和其他错误,但ApiController中的异常不会显示在Elmah中.
知道怎么解决这个问题吗?
<modules>
<remove name="FormsAuthenticationModule" />
<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>
<elmah>
<security allowRemoteAccess="yes" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="XXX"/>
</elmah>
public class StatusController : ApiController
{
private StatusBLL statusBLL = new StatusBLL();
// POST api/status
public void Post(StatusDTO status)
{
throw new ArgumentException("test elmah here");
if (!statusBLL.Register(status))
helpers.BusinessLayer.CreateResponseApiMessage(statusBLL.Errors);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试将一堆ASP.Net MVC网站迁移到Azure.在这个过程中,我注意到Elmah不能在任何这些网站上运行.我创建了最简单的案例来测试,发现它也不起作用.
在Azure上我创建了一个"标准层"网站,我没有进一步配置它.
在Visual Studio中,我创建了一个新的ASP.NET MVC网站.我添加了Nuget"Elmah"包.我在web.config中将一行更改为:
<security allowRemoteAccess="true" />
Run Code Online (Sandbox Code Playgroud)
这个更改是为了让我查看elmah页面.(我知道不安全,但只是想证明一点)
我还更改了控制器,以便单击about菜单会生成异常.否则这是一个通用的MVC网站.本地一切都很好,我可以生成异常并看到它显示在Elmah.axd页面上,但是一旦我将网站部署到Azure,Elmah页面上就不会显示任何数据.
我已将样本保留在线以用于演示目的:
接下来访问:http://testelmah.azurewebsites.net并点击.您应该看到一条错误消息,指出发生了异常.
对Elmah不工作感到困惑
我花了几个小时搜索解决方案,似乎Elmah只适用于Azure中的其他所有人.我错过了什么?
elmah ×10
asp.net ×6
asp.net-mvc ×5
c# ×3
azure ×1
elmah.mvc ×1
iis ×1
iis-7 ×1
sql-server ×1
web-config ×1
xml ×1