Fastify is a robust framework for Node.js developers to build neat, secure, and scalable applications. It has internal infrastructure to help with logging, testing, and error handling.
In this blog, we will teach you how to use factories and plugins, and how to handle environment variables while building your applications.
Pino, the fastest logger for Node.js, provides the logging functionality for Fastify. Maintained by four collaborators, Pino boasts of 22 million average monthly downloads.
While this output is correct, it may be considered hard to read. An alternative is to use the pino-pretty package, which improves the log output.
When the terminal is started, the output message is much more verbose. However, if a human does not read the logs in the terminal, they should be logged in JSON format.
The way Pino is set up makes it easy to handle the system's failure mode. The transport runs in a separate thread, making asynchronous processing easy even if the system crashes.