Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
187
rated 0 times [  193] [ 6]  / answers: 1 / hits: 6761  / 4 Years ago, fri, july 10, 2020, 12:00:00

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.com/package/log4js


More From » reactjs

 Answers
2

There 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.



  1. Create an endpoint that your app can HTTP POST log data to. This endpoint will then invoke your log4js logger

  2. Have the client request that endpoint whenever it needs to log data, and send the associated data in the request


[#3222] Wednesday, July 8, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tyemathewj

Total Points: 484
Total Questions: 107
Total Answers: 111

Location: Equatorial Guinea
Member since Sun, Feb 14, 2021
3 Years ago
;