如果 Elmah 无法访问数据库来记录异常该怎么办?
好吧,显然相关的问题似乎并没有直接解决这个问题。 Elmah 遇到异常,也许存储库无法访问数据库,但 Elmah 也无法访问该数据库。即使他们针对不同的服务器,也可能是网络问题。
有没有办法为 Elmah 配置后备日志以应对此类情况,例如文本文件、消息队列、电子邮件、短信等?如果是这样,我从哪里开始寻找这样做,除了现在的 Elmah 源代码。
OK, apparently related questions dont seem to address this directly. An exception reaches Elmah, maybe a repository cant reach a database, but then neither can Elmah reach that database. Even if they target different servers, maybe its a network problem.
Is there a way to configure fallback logs for Elmah for cases like this, e.g. a text file, message queue, email, sms, etc? If so, where do I start looking to do this, excpt for now the Elmah source code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通常不太关心这一点:如果数据库没有运行,那么我的应用程序就没有运行,而且无论如何我都没有例外可以记录。但如果这对您来说是个问题,那么您可以考虑使用
XmlFileErrorLog
。据我所知,您不能使用多个日志目的地,并且没有什么比后备更好的了。不过,您可以配置电子邮件通知,但随后您也可以通过电子邮件收到所有例外情况。
这是一篇关于 elmah 的好文章。
I am usually not so concerned about that: If the DB is not running then my application is not running and I have no exceptions to log anyway. But if this is an issue for you then you could consider to use the
XmlFileErrorLog
.As far as I can tell you cannot use more then one log destination and there is nothing like a fallback. You could however configure email notifications, but then you would get all exceptions by email as well.
Here is quite a nice article about elmah.
我发布了一个复合错误日志,它正好解决了这个问题。
您可以通过 Nuget 安装它或从 来源到您的项目中。
配置文件的基本用法:
I released a composite errorlog which address exactly this issue.
You can install it via Nuget or copy it from sources into your projects.
Basic usage from config file :