Closed FluffyDiscord closed 2 years ago
According to https://github.com/pinojs/pino-pretty#programmatic-integration, the alternative is to use pino-pretty transport
which writes onto stdout
by default.
So, you would need something like this:
const pino = require('pino')
const transport = pino.transport({
targets: [{
level: 'info',
target: 'pino-pretty' // must be installed separately
}, {
level: 'trace',
target: 'pino/file',
options: { destination: '/path/last.log' }
}]
})
const logger = pino(transport)
With this approach only console output is formatted, but the log file is still a raw json. I would like to have pretty formatted output in both
pino-pretty
transport writes to stdout
by default but "the options.destination property may be set to log pretty logs to a file descriptor or file." see pino-pretty transport
Like so:
const pino = require('pino')
const transport = pino.transport({
targets: [{
level: 'info',
target: 'pino-pretty'
}, {
level: 'info',
target: 'pino-pretty',
options: { destination: '/tmp/last.log' }
}]
})
const logger = pino(transport)
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
As the
prettyPrint
option is deprecated, how can I output pretty printed log to two streams - console and file - at the same time ?Currently I am using configuration bellow which works fine for me for now