request.log

A child logger bound to the current request with its reqId.

Since Fastify 5 Spec ↗

Syntax

request.log.info(obj?, msg?)

Returns

Logger — A Pino child logger scoped to the request.

Examples

import Fastify from 'fastify';

const app = Fastify({ logger: true });

app.post('/cats', async (req) => {
  req.log.info({ body: req.body }, 'creating cat');
  return { ok: true };
});

Notes

Prefer request.log over the instance logger inside handlers so every line carries the reqId for correlation. Avoid logging secrets; configure Pino redaction in the logger options.