Logging errors in Reactjs (Client-side) application is an important part of software development. Both in development and production mode. However, when it comes to client-side applications, logging is something that often gets overlooked, and options available for you are limited. In this article I will explain how to implement your own logging mechanism using ReactJs and node for free. No paid services are used.
What we are going to do ?
Step 1: Setup node server to support logging
Winston is designed to be a simple and universal logging library with support for multiple transports. A transport is essentially a storage device for your logs. Each instance of a winston logger can have multiple transports configured at different levels. For example, one may want error logs to be stored in a persistent remote location (like a database), but all logs output to the console or a local file.
There also seemed to be a lot of logging libraries out there that coupled their implementation of logging (i.e. how the logs are stored / indexed) to the API that they exposed to the programmer. This library aims to decouple those parts of the process to make it more flexible and extensible.
Let's setup express server to support logging using "winston".