node.jsloggingfastify

How to format fastify logs as logfmt


We have very strict rule: all microservices should write their logs using logfmt format. By default, fastify using json formatting. This is the only thing that stops us from using this framework.

I want fastify to write logs using logfmt formatting. Are there any ways to achieve this?


Solution

  • Fastify uses pino logger under the hood so you need a pino transport to have it: https://github.com/pinojs/pino/blob/master/docs/transports.md

    If it misses, you may implement and then fastify will work consequently