admin管理员组文章数量:1405600
I maintain logs for my backend node js using log4js and it works fine. But I want to do the same for my front end, But I couldn't find a proper package to do that and also in some blogs I came to know that we cannot maintain files in client-side.
So How do I maintain logs for the react js front end?
Note: I want to maintain logs for both info and error, just like this package
I maintain logs for my backend node js using log4js and it works fine. But I want to do the same for my front end, But I couldn't find a proper package to do that and also in some blogs I came to know that we cannot maintain files in client-side.
So How do I maintain logs for the react js front end?
Note: I want to maintain logs for both info and error, just like this package https://www.npmjs./package/log4js
Share Improve this question asked Jul 10, 2020 at 21:46 Rittesh P.VRittesh P.V 4233 gold badges10 silver badges21 bronze badges2 Answers
Reset to default 3There are many ways to do this. However, assuming you want to centralize all of your applications logs in one place, then you must call an endpoint that your application exposes and pass the related log data to that endpoint.
- Create an endpoint that your app can HTTP POST log data to. This endpoint will then invoke your log4js logger
- Have the client request that endpoint whenever it needs to log data, and send the associated data in the request
One way to log the front end with third party packages is to use sentry io
. Either the cloud or self hosted versions act as a centralized place for log management. Since it is started as a separate service, even if your backend goes down, it is still possible to trace your frontend logs.
本文标签: javascriptHow to maintain logs for front end in react jsStack Overflow
版权声明:本文标题:javascript - How to maintain logs for front end in react js? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744315146a2600225.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论