Book Image

Mastering Web Application Development with Express

By : Alexandru Vladutu
Book Image

Mastering Web Application Development with Express

By: Alexandru Vladutu

Overview of this book

Table of Contents (18 chapters)
Mastering Web Application Development with Express
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Logging


Logging can be used to understand the behavior of a web application and detect potential problems. It should be considered as important as unit testing when creating an application. It's not only useful for tracking down bugs but also for other reasons:

  • Performing business analysis

  • Used in conjunction with other tools to trigger alerts

  • Creating various statistics

  • Performance analysis

Bunyan – a battle-tested logger

There are lots of logging modules in NPM that we can use. However, in this chapter, we will focus on bunyan (https://www.npmjs.org/package/bunyan). This module has been battle-tested in production at Joyent and has a lot of useful features, as follows:

  • Logs are structured using the JSON format

  • It has the ability to specify custom destinations for logs (such as custom streams, files, and logfile rotation)

  • It provides support for the custom serialization of objects (it comes bundled with serializers for the request, response, and error objects)

  • It comes with a great CLI tool that...