有没有办法使用ELMAH全局处理常规ASP.NET Web服务(asmx)中的异常,就像我们在ASP.NET网站中一样?
我已经使用NuGet 为MVC安装了Elmah,我能够在db中登录成功错误.唯一的问题是我无法访问/elmahURL来访问错误日志页面.
这是我配置的一部分,如果我有任何错误配置,请指出一下吗?
谢谢
错误
403 - 禁止访问:访问被拒绝.
您无权使用您提供的凭据查看此目录或页面.
在我的web.config:
<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.disableHandleErrorFilter" value="false" />
<add key="elmah.mvc.requiresAuthentication" value="true" />
<add key="elmah.mvc.allowedRoles" value="Administrator" />
<add key="elmah.mvc.route" value="elmah" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
在global.asax:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("elmah.axd");
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", …Run Code Online (Sandbox Code Playgroud) 如何创建ELMAH SQL Server数据库?我通过NuGet将它添加到我的ASP.NET MVC项目中,并且我的机器上没有sql脚本.
back-story:我们主要使用AWS来处理所有事情(托管,数据库,通知等).现在,我正在考虑将数据库端移动到SQL Azure,因为我们已经在AWS RDS上获得了疯狂的账单.所以我尝试做的就是在SQL Azure中创建一个数据库并更新连接字符串以指向新数据库.在过去,ELMAH(这个特定的实现:https://github.com/alexanderbeletsky/elmah.mvc)过去完美无缺.
当前情况:我刚刚在SQL Azure中创建了一个新数据库,并立即注意到主要差异,即不支持:
ON [PRIMARY],NONCLUSTERED KEYS等
我迁移了我的数据库(现在),但是当我将更新的ELMAH脚本应用到数据库并尝试进入该工具时,我收到错误!
我在某种程度上确信这是一个数据库问题,因为如果我删除:
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="DefaultConnection"/> 基本上默认ELMAH在本地存储所有内容,我就可以访问ELMAH.
有人让ELMAH在SQL Azure上工作吗?你能给我一个SQL脚本来生成表和存储过程吗?
我正在使用elmah(v1.1.11517.0)并尝试将配置移动到外部源.
我的配置目前看起来像这样:
<?xml version="1.0"?>
<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>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net configSource="Settings\RobDev\log4net.config" />
<elmah configSource="Settings\RobDev\ELMAH.config" />
</configuration>
Run Code Online (Sandbox Code Playgroud)
log4net很高兴并且运行良好,但是对于elmah我得到了错误
Parser Error Message: The attribute 'configSource' cannot be specified because its name starts with the reserved prefix 'config' or 'lock'.
Run Code Online (Sandbox Code Playgroud)
这是一种痛苦,elmah文件肯定存在,但有些事情并不快乐.
可能是什么导致了这个?
我刚为我的ASP.NET应用程序安装了Elmah(https://code.google.com/p/elmah/).是否可以在不先创建异常的情况下记录消息?
catch(Exception e)
{
Exception ex = new Exception("ID = 1", e);
ErrorSignal.FromCurrentContext().Raise(ex);
}
Run Code Online (Sandbox Code Playgroud)
那么有可能做到:
ErrorSignal.FromCurrentContext().log("Hello I am testing Elmah");
Run Code Online (Sandbox Code Playgroud) 我们有一个SQL日志用于存储来自多个应用程序的错误.我们已经为每个应用程序禁用了elmah.axd页面,并希望有一个新的应用程序,专门显示报告错误的所有应用程序中的错误到常见的SQL日志.
截至目前,即使所有错误的应用程序都使用通用SQL日志,它也只显示当前应用程序的错误.有没有人这样做过?elmah代码中可能需要调整什么?
我正在尝试配置ELMAH来过滤404错误,我在Web.config文件中遇到了XML提供的过滤规则.我按照这里和这里的教程,<is-type binding="BaseException" type="System.IO.FileNotFoundException" />在我的<test><or>...声明中添加了一个声明,但完全失败了.
当我在本地测试它时,我void ErrorLog_Filtering() {}在Global.asax中插入了一个断点,并发现System.Web.HttpExceptionASP.NET为404 启动的那个似乎没有基本类型System.IO.FileNotFound,而是它只是一个System.Web.HttpException.我通过调用e.Exception.GetBaseException().GetType()事件处理程序来测试它.
接下来我决定尝试一个<regex binding="BaseException.Message" pattern="The file '/[^']+' does not exist" />希望任何匹配模式"文件'/ foo.ext'不存在"的异常消息将被过滤,但这也没有效果.作为最后的手段我尝试过<is-type binding="BaseException" type="System.Exception" />,甚至完全无视.
我倾向于认为ELMAH存在配置错误,但我没有看到任何错误.我错过了一些明显的东西吗?
这是我的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" />
</sectionGroup>
</configSections>
<elmah>
<errorFilter>
<test>
<or>
<equal binding="HttpStatusCode" value="404" type="Int32" …Run Code Online (Sandbox Code Playgroud) 我发现这很容易设置; 要么设置配置中缺少一步,它没有正常工作,或者我实际上并不理解它的用途.这里肯定有一些错误.问题显然必须是我.我只是没有让这个工作.这就是我所做的.
创建一个全新的mvc应用程序.在About.aspx页面上放置以下内容.
<%throw new Exception("blah"); %>将内容放在此处.
点击页面获取黄色屏幕异常.
将elmah.dll添加到bin目录.
添加到Web.config文件configurationSections:
<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>
Run Code Online (Sandbox Code Playgroud)
将以下内容添加到httpHandlers部分:
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
Run Code Online (Sandbox Code Playgroud)
添加到模块部分:
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
Run Code Online (Sandbox Code Playgroud)
添加到处理程序部分:
<add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" preCondition="integratedMode" type="Elmah.ErrorLogPageFactory, Elmah"/>
Run Code Online (Sandbox Code Playgroud)
添加一个elmah部分:
<elmah>
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>
Run Code Online (Sandbox Code Playgroud)
这里很奇怪的是,该字符串的".XmlFileErrorLog"部分显示为红色,因为ReSharper错误表明它"无法解析符号'.'''当我在Reflector中查看elmah.dll时显示此对象需要两个公共构造函数中的任何一个中的"字符串"或"IDicationary".
我正在使用VS 2008运行Windows Vista x64.将App_Data的权限设置为Everyone作为Co_Owner.
该HTTP://本地主机:XXXX/elmah.axd页面不上来,并显示没有错误.当我再次点击"关于"页面时,我仍然看到黄色屏幕,elmah.axd仍然显示app_data文件夹没有错误.
我替换了customerrors并创建了相关的页面:
<customErrors mode="On" defaultRedirect="GenericErrorPage.htm" />
Run Code Online (Sandbox Code Playgroud)
自定义页面显示,但elmah.axd仍显示"无错误".App_data仍然是空的!
作为启动此设置的来源,我使用了:code.google.com/p/elmah/wiki/MVC …
如何删除Elmah在服务器上生成的日志文件?
Elmah中是否有可用于删除日志文件的设置?我更愿意指定一些标准(例如,超过30天的日志文件).
或者我应该为此编写自己的代码?
elmah ×10
asp.net-mvc ×5
asp.net ×3
elmah.mvc ×2
asmx ×1
azure ×1
configsource ×1
filtering ×1
nuget ×1
web-config ×1
web-services ×1