pino
pino copied to clipboard
Configuration ignored when multiple transport targets
The formatter and timestamp are disregarded when using the following configuration:
const transports = pino.transport({
targets: [
{
level: 'info',
target: 'pino/file',
options: { destination: `${logDir}/svc_info.log`, mkdir: true, }
},
{
target: 'pino/file',
options: { destination: `${logDir}/svc_error.log`, mkdir: true, }
}
]
});
const logger = pino({
level: 'info',
formatters: {
level(label) { return { level: label }; },
},
timestamp: pino.stdTimeFunctions.isoTime
}, transports)
I still see the log level number (rather than label) and epoch time in ms. If I use just one of the transports (i.e., not the array syntax), it works as expected.
Unfortunately we need levels to be a number for multistream to work. Essentially the level formatter is incompatible with transports. We need to throw a better error.
I would love to have some code that implements it, however I do not think it's possible.
Is there another way to achieve this same result?
Ran into the same thing. Is there a way to add level as string when using multiple transports? Also why is it not possible?
Same here, are there any updates on this?