Fastify: Duplicate req id in incoming request log

Created on 9 Jul 2018  路  3Comments  路  Source: fastify/fastify

The default logger output request id twice in the "incoming request" log record. As the request id may be not so short, this is a waste of log size.

A sample log is below, where the req id is generated by nanoid module.

{"level":30,"msg":"incoming request","reqId":"zvTdkL3H_Pm3NeSgG0ByD","req":{"id":"zvTdkL3H_Pm3NeSgG0ByD","method":"GET","url":"/ping","remoteAddress":"127.0.0.1","remotePort":61820},"v":1}

I think the req.id field could be removed to retain the reqId field to keep accorded with "request completed" log.

Context

  • node version: 10
  • fastify version: ^1.7.0
  • os: Mac
feature request help wanted

All 3 comments

I think we can drop the req.id property in the serializer (https://github.com/fastify/fastify/blob/master/lib/logger.js#L43). Would you like to send a PR?

see #1032

Closed in #1032.
This feature will land in the next major release of the framework :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jsumners picture jsumners  路  4Comments

rabbitooops picture rabbitooops  路  3Comments

lgertel picture lgertel  路  3Comments

lfurzewaddock picture lfurzewaddock  路  3Comments

lean picture lean  路  3Comments