In this post we will be discussing about better logging in Node.js. If you are writing an application, detailed logging is required for spotting problems and debugging. Logging is an integral part of any application. A well implemented logging mechanism in the application reduces the time to identify the root cause of the problem.
But developer should be careful on how much amount of logging should be done, thus in this post we will be going through some of the npm packages which will be helpful in reducing the amount consumed by the developer to do logging.
But it definitely does not serve our purpose for better logging because it lacks the feature of time-stamps, we cannot distinguish between the info and error and also the severity of the error cannot be distinguish.
There are number of modules which can help us in doing the logging right for our application. Here we will be discussing about Winston and Bunyan.
Bunyan: As per Bunyan, it is a simple and fast JSON logging library for nodejs services. They also have a Bunyan CLI tool for nicely viewing the logs.
Winston: As per Winston, it is a multi-transport async logging library for node.js. Winston is designed to be a simple and universal logging library with support for multiple transports.
Create a file name example6.js whose contents will be "
Which one to use : Winston or Bunyan ?
Winston and Bunyan are both established logging frameworks and have lot of features. It all depends on the preference and how easy it to integrate in your application.
Please Like and Share the Blog, if you find it interesting and helpful.