你做客户端日志记录吗?
使用 Flex 和 Silverlight 构建 RIA 应用程序时,如何捕获客户端发生的错误?常见做法有哪些?我已经看到一些异步 js 调用已实现的 Web 服务,但想知道社区是如何处理它的。
How do you capture errors that happen on client side when building RIA apps using Flex and Silverlight? What are the common practices? I have seen some asynch js calls to a web service implemented but would like to know how the community is dealing with it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
首先,我一直使用客户端日志记录。
我处理它的方式取决于整个应用程序。
如果我使用 AMF 网关,则会调用应用程序错误,发生的每个错误都会通知服务器,在服务器端,BugZilla 中会出现一个错误(这就是我们使用的,您可以使用您想要的任何其他钩子) )。
如果我使用基于 Web 服务的应用程序,则会出现客户端错误的 Web 服务调用。
有人会说你不应该对每个错误都对服务器进行采样,我不同意这个评论,因为客户端的错误很少见,它在发布给客户端之前会进行彻底的质量检查,所以我想立即知道客户端的每个错误正在经历。
First, I use client side logging all of the times.
the way I handle it depends on the entire application.
if I use an AMF gateway then there's a call for an application error, with every error that occurs the server is notified, in the server side a bug is open in BugZilla (this is what we use, you can use any other hook you want).
If I use a web-service based application then there's a web-service call for a client error.
one would say you shouldn't sample the server with every error, I disagree with this comment because an error in the client side is rare, it goes thorough QA before being released to the client so I want to know immediately on every error the client is experiencing.
在 Silverlight 中,我喜欢使用 WebClient 重新登录到某处的 Web 服务——您可以直接在 Silverlight 应用程序中执行此操作,而无需调用 JavaScript。
要捕获代码不在堆栈上时引发的异常,可以使用 Application.UnhandledException 事件。
In Silverlight I like to use a WebClient to log back to a web service somewhere -- you can do this directly in the Silverlight application without calling out to JavaScript.
To catch exceptions that are fired when your code isn't on the stack, you can use the Application.UnhandledException event.
我使用了与 Avi Tzurel 相同的方法 - 当 Flex 客户端中出现错误时,您需要在服务器端知道。如果您想收集更多数据(所有日志消息、警告),我将使用内部缓冲区,并异步刷新它。
无论如何,您需要考虑您的客户是否同意这种方法。也许您需要他们的同意才能将错误消息发送到服务器。
I've used the same approach as Avi Tzurel - you need to know on the server side when an error appeared in the Flex client. If you want to collect more data (all the log messages, warnings) I would use an internal buffer and I will flush it asynchronously.
Anyway, you need to take into consideration if your customers are ok with this approach..maybe you need their agreement before sending the error message to the server.
我基本上将所有错误渗透到顶部,并在未处理的异常中捕获它们。我向用户显示一条友好的消息。然而,在我的应用程序中,我实现了一个 ILogger 接口。该接口可以用不同的级别进行初始化并处理任何消息传递。您可以对其进行设置,以便用户可以添加一个 init 参数来确定是否将错误传输到服务,并且如果附加了调试器,我通常会让记录器使用 Debug.WriteLine 写入消息,以使其非常容易在调试模式下跟踪问题。
I basically percolate all errors to the top, and capture them in the unhandled exception. I display a friendly message to the user. However, throughout my application I implement an ILogger interface. This interface can be initialized with various levels and handles any messaging. You can set it up so the user can add an init param to determine whether or not to transmit the errors to a service, and I typically have the logger write the messages with Debug.WriteLine if the debugger is attached to make it very easy to trace issues in debug mode.
在 Silverlight 中,您可能需要考虑 Silverlight 集成包中的日志记录和异常处理应用程序块对于企业库。
In Silverlight you may want to consider the Logging and Exception Handling Application Blocks from the Silverlight Integration Pack for Enterprise Library.