#Express - Logging Express comes with a built-in logging module called logger and you can use it just like any other Express module:
app.use(express.logger());
Without any configuration, the logger middleware will generate a detailed log. If you prefer, you can customize the details with the following options to format the output of the logger:
Token | Content |
---|---|
:req[header] | The specific HTTP header of the request |
:res[header] | The specific HTTP header of the response |
:http-version | The HTTP version |
:response-time | How long it took to generate the response |
:remote-addr | The user agent's IP address |
:date | Date and time of request |
This all still seems valid, but
logger
now needs to be installed separately and has been renamedmorgan