I can't change the default option
- { level: info }
in the Pino settings for Fastify.
The other options
work as they should.
I have a project with the structure:
- project/
- node_modules/
- plugins/
- pino/
- config/
- config.js
- dev.js
- logs/
- dev.log
- config/
- routes/
- home.js
- app.js
- package-lock.json
- package.json
app.js
import fastify from 'fastify'
const { default: pino } = await import('./pino/config/config.js')
const app = fastify({ logger: pino.dev })
await app.register(import('./plugins/env/plugin.js'))
await app.register(import('./routes/home.js'))
await app.listen({ port: process.env.PORT || 5500 })
pino/config/config.js
const { default: dev } = await import('./dev.js')
// const { default: prod } = await import('./prod.js')
// const { default: test } = await import('./test.js')
export default {
dev,
// prod,
// test,
}
pino/config/dev.js
const targets = [
{
target: 'pino-pretty',
options: {
name: 'dev-terminal',
level: 'error', // It should be 'error', but it works as 'info' (default value)
// setting pino-pretty
colorize: true,
levelFirst: true,
include: 'level,time,',
translateTime: 'yyyy-mm-dd HH:MM:ss Z',
},
},
{
target: 'pino/file',
options: {
name: 'dev-local-file',
level: 'fatal', // It should be 'fatal', but it works as 'info' (default value)
destination: './pino/logs/dev.log',
mkdir: true,
},
},
]
export default {
transport: {
targets,
},
}
Can I do without disableRequestLogging
?
The option are in the wrong order, here a working example: