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.

1 Answer 1


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.

  • Thank you for your answer. About sending logs from the client to the server, if i have a server public API (a controller) to which i can send error logs and messages, wouldn't that be an API route that can be used by anyone to write any message to the server?
    – Uentee
    Commented Mar 19, 2018 at 12:04
  • Sure, you’d want to protect it like any other exposed endpoint. Use credentials, encryption, maybe xsrf tokens, etc.
    – Paul
    Commented Mar 19, 2018 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.