morgan npm code example

Example 1: morgan npm

morgan(function (tokens, req, res) {  return [    tokens.method(req, res),    tokens.url(req, res),    tokens.status(req, res),    tokens.res(req, res, 'content-length'), '-',    tokens['response-time'](req, res), 'ms'  ].join(' ')})

Example 2: morgan formats

#combined
:remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user
#common
:remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length]
#dev
:method :url :status :response-time ms - :res[content-length]
#tiny
:method :url :status :res[content-length] - :response-time ms

Tags:

Misc Example