使用 Global.aspx 页进行错误报告
我一直无法从收到的错误报告中识别应用程序中的错误。 目前,我建立了一封电子邮件,其中包含有关错误的信息。
- 用户
- 网址
- 错误消息
- 时间和日期
这是我使用的代码
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim _UserIpAddress as string = Request.ServerVariables("REMOTE_ADDR")
Dim _Browser as string = Request.ServerVariables("HTTP_USER_AGENT")
Dim _URL as string = Request.Url.AbsoluteUri
Dim _ErrorDate as string = System.DateTime.Now
Dim _Error as string = Server.GetLastError().InnerException.ToString()
End Sub
问题是在某些情况下使用此信息我无法找出导致错误的原因。
我如何获得有关错误的更多详细信息? 例如,是什么控制导致了它,系统中传递的变量中的数据
以及您使用了除电子邮件之外的哪些收集数据的方法以及它们的成功程度。 例如登录数据库、在文本文件中重新编码等。
I have always had issues with identifying the errors in applications from the error reports I get. Currently I build an email with information about the error containing.
- User
- Url
- Error Message
- Time And Date
This is the code I use
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim _UserIpAddress as string = Request.ServerVariables("REMOTE_ADDR")
Dim _Browser as string = Request.ServerVariables("HTTP_USER_AGENT")
Dim _URL as string = Request.Url.AbsoluteUri
Dim _ErrorDate as string = System.DateTime.Now
Dim _Error as string = Server.GetLastError().InnerException.ToString()
End Sub
The issue is that with this information in some cases I cant work out what has caused the error.
How would I get some more detail on the error? e.g what control caused it, the data in the variables being passed in the system
Also what methods of collecting the data other than email have you used and how successful have they been. e.g. logging in a database, recoding in a text file etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
例如,没有通用的方法来捕获所涉及的变量。 您几乎要求在出现错误时进行转储! 即便如此,您也必须弄清楚用户在错误发生之前做了什么。 您可以从 IIS 日志中获取一些帮助(如果引用 URL 不为空,您还应该记录它)。
这个问题的真正答案是一个难题:更好的质量保证。 上线后发生的错误越少,您需要解决的错误就越少。
通过自动化单元测试(尤其是使用测试驱动开发)发现错误,可以进一步减少 QA 中发现的错误数量。
There's no general method of capturing the variables involved, for instance. You're pretty much asking that a dump be taken whenever you get an error! Even so, you'd have to figure out what the user had been doing before the error occurred. You can get some help from the IIS logs (and you should also log the Referrer URL if it's non-null).
The true answer to this problem is a hard one: better QA. The fewer errors that happen once you've gone live, the fewer you'll have to figure out.
The number of errors found in QA can be further reduced by finding them through automated unit testing, especially using Test-Driven Develpopment.