防止 log4net 通过 SMTP 发送重复问题
我们已经使用 SMTP 将 log4net 与 Jira 桥接起来。
现在我们担心,由于该站点是公共的,如果我们在生产环境中遇到很多问题,Jira 服务器可能会发生什么情况。
我们已经过滤了“严重”和“致命”,但我们希望看到 log4net 上的一些累加器服务或普通过滤器,该过滤器可以识别重复问题并阻止它们通过电子邮件发送。最好不必更改错误报告代码,因此配置解决方案将是最好的。
我想将日志转储到数据库中,然后创建一个单独的监听器,一些智能代码将是一个(昂贵的)替代方案。
we have bridged our log4net with Jira using SMTP.
Now we are worried that since the site is public what could happen to the Jira server if we get alot of issues in the production environment.
We have already filtered on Critical and Fatal, but we want to see either some acumulator service on log4net or a plain filter which identifies repeating issues and prevents them from being sent via Email. Preferably without having to change the error reporting code, so a config solution would be best.
I guess dumping the log into a db and then create a separate listener some smart code would be a (pricy) alternative.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许这个 足以满足您的要求:
它基本上限制了在给定时间范围内发送的电子邮件数量。我认为根据您的需求定制它应该很容易。我做了类似的事情,甚至在一定时间范围内丢弃消息:
可以像其他附加程序的正常设置一样配置刷新间隔:
Maybe this is sufficient for your requirements:
it basically limits the number of emails that are sent in a given time span. I think it should be quite easy to customize this to your needs. I did something similar that even discards messages within a certain time span:
The flush interval can be configured like normal settings of other appenders:
您还可以使用带有 log4net.Core.TimeEvaluator< 的普通 SmtpAppender /a> 作为评估者。
假设我们有 5 分钟的间隔,事件发生在 00:00、00:01 和 01:00。
您想要哪一种取决于您是否更担心有保证的延迟或潜在的大延迟。
我尝试将 SmptThrotdlingAppender 与 TimeEvaluator 结合起来,但无法获得我想要的行为。我开始怀疑我应该编写一个新的 ITriggeringEventEvaluator,而不是一个新的 IAppender。
You can also use a plain SmtpAppender with a log4net.Core.TimeEvaluator as the Evaluator.
Suppose we have an interval of 5 minutes, and events at 00:00, 00:01 and 01:00.
Which one you want depends on whether you're more bothered by the guaranteed delay or the potentially large delay.
I attempted the combine the SmptThrottlingAppender with a TimeEvaluator, but couldn't get the behaviour I wanted. I'm beginning to suspect that I should be writing a new ITriggeringEventEvaluator, not a new IAppender.