NextJS如何在发生错误时发送客户端日志

huangapple go评论66阅读模式
英文:

NextJS how to send client logs when error occurs

问题

我们在NextJS中有一个静态渲染,并且偶尔一些用户会收到“应用程序错误:发生了客户端异常”这是NextJS用于致命错误的捕获页面。我找不到如何捕获这些错误并将它们发送到某个地方以便进行调试。我确实看到有关“_error”页面的一些信息,但这实际上是404页面。有关如何捕获客户端致命错误并将其记录到某个地方的任何见解吗?

英文:

We have a static rendering for NextJS and occasionally some users receive Application error: a client-side exception has occurred which is the catch-all page for a fatal error using NextJS. I couldn't find how how to catch these errors and send them somewhere so they can be debugged. I did see something about an _error page but this is actually the 404 page. Any insights on how to catch the client-side fatal errors and log them somewhere?

答案1

得分: 1

你可以使用像Sentry这样的服务来监控这些错误。

查看文档:

https://nextjs.org/docs/advanced-features/error-handling#reporting-errors
https://github.com/vercel/next.js/tree/canary/examples/with-sentry

英文:

You can use a service such as Sentry to monitor these errors.

See docs:

https://nextjs.org/docs/advanced-features/error-handling#reporting-errors
https://github.com/vercel/next.js/tree/canary/examples/with-sentry

huangapple
  • 本文由 发表于 2023年2月24日 06:13:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75550862.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定