PinoWarning: prettyPrint is deprecated, look at https://github.com/pinojs/pino-pretty for alternatives

3.1k Views Asked by At

I suddenly started getting following error in my nodejs project

[PINODEP008] PinoWarning: prettyPrint is deprecated, look at https://github.com/pinojs/pino-pretty for alternatives.

What to do? App is crashing

(Use `node --trace-warnings ...` to show where the warning was created)
[nodemon] app crashed - waiting for file changes before starting...
2

There are 2 best solutions below

0
On

If you are looking for the solution of [PINODEP008] PinoWarning: prettyPrint is deprecated, look at https://github.com/pinojs/pino-pretty for alternatives, then, I solved the same in my application, as below:

Instead of

pinoHttp: {
    prettyPrint: {
        ignore:'req.headers,res',
    }
}

Updated this:

pinoHttp: {
    transport: {
        target: 'pino-pretty',
        options: {
            ignore:'req.headers,res',
        }
    }
}

Reference: https://github.com/Zialus/TW-Minesweeper-Server/commit/f67ae7e33434fd36d14760f1c5572cefd52bae92

0
On

Old way:

prettyPrint: true     

New way:

transport: {
  target: "pino-pretty",
  options: {
    levelFirst: true,
    translateTime: true,
    colorize: true,
  },
},