Closed tianheg closed 4 months ago
I don't think the pino transport system would work on vercel. You should use it as a stream: https://github.com/pinojs/pino-pretty?tab=readme-ov-file#usage-as-a-stream.
Use pino-pretty as a stream worked, here is the code:
import Fastify from 'fastify';
import pino from 'pino';
import pretty from 'pino-pretty';
const stream = pretty({
translateTime: 'SYS:HH:MM:ss Z',
messageFormat: '{msg} {req.method} {req.url}',
include: 'time,pid,level',
hideObject: true,
colorize: false,
});
const logger = pino({ level: 'info' }, stream);
const app = Fastify({ logger });
Thanks for your reply
Prerequisites
Fastify version
4.26.2
Plugin version
1.3.0
Node.js version
20.x
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Vercel Serverless
Description
I use
@fastify/one-line-logger
format logs, when deploying fastify as Vercel's serverless function, get below error:Steps to Reproduce
@fastify/one-line-logger
Expected Behavior
The fastify api will deploy successfully on vercel