英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论