What are the fields for the default express console output?

15 views Asked by At

When you start a an express server using express-generator you get a single-line output for each request that looks a bit like this

GET /images/07777c4bc2aebaff6964a46b7c3714f3.png 200 2.730 ms - 15919

What are the space delimited fields? The first 4 are self evident, but the last 2 aren't.

  • http verb
  • endpoint
  • http status
  • number of ms required to generate and send the response
  • ?
  • ?
1

There are 1 answers

2
Native Coder On

I found it. Turns out the express-generator generates the following code

const logger = require( "morgan" );
app.use( logger( "dev" ) );

In other words, express uses morgan as its default logger. It puts morgan in dev mode. When morgan is in dev mode it generates the following fields

:method :url :status :response-time ms - :res[content-length]

Documentation