0

For logging in nestjs I implemented pino as described here: https://github.com/iamolegga/nestjs-pino.

When there is an error throw during the initialization of the nestjs modules, the default nestjs logger is used instead of pino. When the initialization does not throw an error, pino is used correctly.

Maybe the issue occurs because logs are buffered by bufferLogs: true in main.ts? And this does not work, if an error is thrown during module init?

Do I maybe have to set the logger before the app is created, as stated here: https://github.com/iamolegga/nestjs-pino/issues/387 (https://github.com/iamolegga/nestjs-pino/issues/125)?

user2625247
  • 361
  • 1
  • 4
  • 15

1 Answers1

1

This is how bufferLogs works, as said in the documentation

If the initialisation process fails, Nest will fallback to the original ConsoleLogger to print out any reported error messages.

If you want to only use the custom logger you'd need to create your own instance of the nestjs-pino logger and pass that to logger instead of using the bufferLogs option

Jay McDoniel
  • 57,339
  • 7
  • 135
  • 147