質問

I basically want to know if it is considered a good practice to persist the errors that happen on the client side of a web application (typescript/angular for example) by logging them to files?

Or if i can ask in a different way: What should i do with the errors/exceptions that i catch on the client side? (besides displaying a visual indicator to the user that something bad happened)

Most logging articles i see only speak of logging to the console.

Thank you.

役に立ちましたか?

解決

So, first you should log (where possible) client generated errors back to your server. This is not always possible for offline stuff, but if you have connectivity, the errors should normally go back to the server, so that you can identify them and correct them in future releases.

Server logs generally should just go to stderr or stdout from the applications perspective,and the server should then direct them to the appropriate file(s) or logging subsystem (eg syslog) for aggregation.

Logging to the client console is generally only useful in development, and you normally won't have access to the client file system at all from a browser, so logging to a clientside file isn't a reliable option at all unless you're making some installable application.

ライセンス: CC-BY-SA帰属
所属していません softwareengineering.stackexchange
scroll top