pino icon indicating copy to clipboard operation
pino copied to clipboard

Configuration ignored when multiple transport targets

Open tasdflkjweio opened this issue 3 years ago • 10 comments
trafficstars

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.

tasdflkjweio avatar Apr 23 '22 00:04 tasdflkjweio

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.

mcollina avatar Apr 23 '22 06:04 mcollina

Is there another way to achieve this same result?

tasdflkjweio avatar Apr 25 '22 17:04 tasdflkjweio

Ran into the same thing. Is there a way to add level as string when using multiple transports? Also why is it not possible?

maidul98 avatar Nov 21 '23 19:11 maidul98

Same here, are there any updates on this?

quallrum avatar Feb 29 '24 13:02 quallrum