限制 Elmah 发送的电子邮件数量
有谁知道有什么好方法可以像健康监控一样限制 Elmah 在一段时间内发送的电子邮件数量?
我希望能够将每个页面中每个错误的电子邮件限制为针对该特定错误和页面每小时左右发送一次电子邮件。
查看 elmah 文档,它看起来像
void ErrorMail_Filtering(object sender, ExceptionFilterEventArgs e)
{
// perform filtering here
}
在 global.ascx 文件中使用:可能是一个选项。我可以为每个应用程序设置一个静态对象,其中包含一些错误详细信息和记录的时间并检查它并在需要时取消电子邮件通知?
有谁有更好的解决方案或他们现在正在使用的示例?
Does anyone know of a good way to limit the number of emails sent by Elmah during a time period like you can with Health Monitoring?
I want to be able to limit the emails for each error from each page to only an email once an hour or so for that particular error and page.
Looking at the elmah documentation it looks like using:
void ErrorMail_Filtering(object sender, ExceptionFilterEventArgs e)
{
// perform filtering here
}
in the global.ascx file might be an option. I could setup a static object per application that contains some the error details and the time logged and check it and cancel the email notification if need be?
Do anyone have a better solution or an example of what they are using now?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我用与你问题中相同的方法写了这篇文章。看起来效果很好。
I wrote this using the same method as in your question. Seems to work nicely.
我不知道 Elmah 是否具有该功能(文档没有提及),但 ASP.NET 的运行状况监控具有: https://web.archive.org/web/20210513222150/http://aspnet.4guysfromrolla.com/articles/032107- 1.aspx
我最终为我的 CMS 编写了自己的事件日志记录、通知和汇总系统...我散列每个异常的堆栈跟踪,并使用它来“汇总”类似事件(一个 Web 应用程序)如果出现问题,可能会在不到一秒的时间内出现数千个异常)。
我将通知期限配置为 1 天 - 每天我只收到第一个错误实例的通知。最新的错误实例始终会被保存,但较旧的实例会被“清理”到最后 20 个左右,具体取决于频率等......
它与身份验证系统集成,因此管理员/开发人员会获得一个“收件箱”他们订阅的事件的数量,并且可以实时查看调试信息,同时防止未经身份验证的用户看到任何调试信息。
真的很好...而且由于它是通用的,它也适用于非错误事件,例如出版物、用户更改通知等。
我很好奇是否有人会对作为库公开的这种系统感兴趣?
I don't know if Elmah has that capability (the docs don't mention it), but ASP.NET's health monitoring does: https://web.archive.org/web/20210513222150/http://aspnet.4guysfromrolla.com/articles/032107-1.aspx
I ended up writing my own event logging, notification, and rollup system for my CMS... I hash the stack trace of each exception and use it to 'roll-up' similar events (a web app may get thousands of exceptions in less than a second if something goes wrong).
I configured my notification period to 1 day - I only get notified of the first instance of an error each day. The latest instance of an error is always saved, but older instances are 'cleaned up' to the last 20 or so, depending upon frequency, etc....
It integrates with the authentication system, so administrators/developers get an 'inbox' of events they have subscribed to, and can look at debug info in real time, while preventing unathenticated users from seeing any debugging info at all.
Really nice... And since it's generic, it works for non-error events also, like publications, user change notifications, etc.
I'm curious if anyone would be interested in that kind of system exposed as a library?
我遇到了类似的问题,并选择对 ELMAH 使用 log-to-SQL 方法。我在 Web 服务器上使用 SQLExpress 2008(免费版),然后设置 SQL 报告以每天早上发送摘要电子邮件。
此方法不需要编码,只需设置 SQL 服务器和报告服务。它的好处是让您可以对数月的错误日志运行报告,而不仅仅是每天查看它们。此外,您还可以根据需要频繁地安排报告。
ELMAH wiki 页面提供了有关如何设置 web.config 以指向 SQL 的信息服务器。一旦数据存储在 SQL 中,就有许多选项可用于获取数据,但我发现 SQL Express 报告服务非常适合我的需求。
I had a similar problem and opted to use the log-to-SQL method for ELMAH. I used SQLExpress 2008 (free-version) on my Web server and then setup SQL Reporting to send digest emails every morning.
This method required no coding, just setup of the SQL server and reporting services. It has the benefit of letting you run reports on months of error logs rather than just seeing them daily. In addition, though, you can schedule reports as frequently as you like.
The ELMAH wiki page has information on how to setup the web.config to point to a SQL server. There are many options for getting the data out, once the data is in SQL but I find the SQL Express reporting services were perfect for my needs.
这个 codeplex 项目 ASP.NET Exception Reporting 是 Elmah 的包装器,看起来很有前途。 http://aspexceptionreporter.codeplex.com/
This codeplex project ASP.NET Exception Reporting which is a wrapper for Elmah looks promising. http://aspexceptionreporter.codeplex.com/