As previously seen, writing a request logger is simple. However, writing our own could take precious time. Luckily, there are several other alternatives out there. For example, a very popular HTTP request logger widely used is morgan https://expressjs.com/en/resources/middleware/morgan.html.
morgan is a configurable middleware function that takes two arguments format and options which are used to specify the format in which the logs are displayed and what kind of information needs to be displayed.
There are several predefined formats:
- tiny: Minimal output
- short: Same as tiny, including remote IP address
- common: Standard Apache log output
- combined: Standard Apache combined log output
- dev: Displays the same information as the tiny format does. However, the response statuses are colored.