ASP.NET - 抛出或记录错误 [英] ASP.NET – Error throwing or logging
问题描述
我们有3层:UI,Business和Database。我们需要澄清错误处理/记录。我们有一个错误记录框架来记录错误。
我的问题是:我们需要在每个层中记录错误或仅在主调用层(UI层)通过从业务和数据库层将错误引入UI层? 是否有最佳做法?
如果您还可以提供参考文档或Web引用(如果需要) p>
谢谢和祝福...
Sruthi Keerthi。
- 处理您可以在它们发生的层中的任何异常。让那些你不能处理泡沫到UI层。请参阅
ASP.NET Web应用程序异常处理建议了解更多信息信息。 - 使用例如 Elmah 的异常记录机制来记录例外情况UI。
We are building an ASP.NET application in C#
We have 3 layers: UI, Business and Database. We need clarification on error handling/logging. We have a error logging framework to log errors.
My question is: do we need to log errors in each layer or only in the main calling layer (UI layer) by throwing the errors to UI layer from business and database layers? Is there a best practice?
If would be great if you could also provide a reference document or web references (If needed).
Thanks and Regards … Sruthi Keerthi.
- Handle any exceptions that you can in the layer that they occur. Let the ones that you can't handle bubble up to the UI layer. See Exception Handling Advice for ASP.NET Web Applications for more information.
- Use an exception logging mechanism like Elmah to log exceptions in the UI.
这篇关于ASP.NET - 抛出或记录错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!