ASP.NET - 错误引发或记录 [英] ASP.NET – Error throwing or logging
问题描述
我们在C#中构建ASP.NET应用程序
We are building an ASP.NET application in C#
我们有3层:用户界面,业务和数据库。我们需要对错误处理/记录澄清。我们有一个错误日志框架记录错误。
We have 3 layers: UI, Business and Database. We need clarification on error handling/logging. We have a error logging framework to log errors.
我的问题是:我们需要在每一层中记录错误或仅在从业务和数据库层抛出错误UI层的主要调用层(UI层)? 是否有最好的做法?
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).
感谢和问候......
Sruthi Keerthi。
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屋!