pinojs / pino

🌲 super fast, all natural json logger
http://getpino.io
MIT License
14.21k stars 875 forks source link

Strange formatting when writing pretty-pino output to .log files #1683

Closed vitoff34 closed 1 year ago

vitoff34 commented 1 year ago

Hello, I am trying to log errors using pretty-pino not only to the console but also to files. This is my code for the logger:

const pino = require('pino');
const transport = pino.transport({
    targets: [{
        level: 'error',
        target: 'pino-pretty' // must be installed separately
    }, {
        level: 'trace',
        target: 'pino-pretty',
        colorize: true,
        options: { destination: 'logs/error.log' }
    }]
})
const logger = pino(transport)

However when the error is added to the error.log there is some strange formatting like this:

ERROR (55774): user is not defined

Additionally in front of every "[" there is something like and ESC emoji. How can I remove this formatting? Thank you

jsumners commented 1 year ago

Don't colorize the output.

vitoff34 commented 1 year ago

I removed the colorize but I still get the strange formatting.

jsumners commented 1 year ago

The characters provided in the issue are terminal color escape sequences.

vitoff34 commented 1 year ago

So there is no way to use colors in .log files?

jsumners commented 1 year ago

You are welcome to write whatever you like to a log file. It's a matter of tooling to interpret them in the way you want.

vitoff34 commented 1 year ago

So I can format in one way in console and another in .log files for pino pretty? Can you show me some code how to achieve this if it is not too much trouble? Thank you

jsumners commented 1 year ago

We have significant documentation around multiple streams. Please open an issue if you find problems with that documentation.

github-actions[bot] commented 1 year ago

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.