NestJS · Senior · Question 34 of 75
How do you make Nest's logs structured and correlated?
- 1Logs can't be customized
- ✓Correct answer: Replace the default logger (e.g.
nestjs-pinoor a JSONConsoleLogger), add request IDs via middleware and ALS, and usebufferLogsso startup logs go through it - 3Use
console.logwith string concatenation
Explanation
NestFactory.create(AppModule, { bufferLogs: true }) then app.useLogger(...) captures logs from the bootstrap phase too.