Given this NestJS Winston logger setup, what will be logged when calling logger.info('Server started')?
import { WinstonModule } from 'nest-winston'; import * as winston from 'winston'; const logger = WinstonModule.createLogger({ transports: [ new winston.transports.Console({ level: 'info', format: winston.format.combine( winston.format.timestamp(), winston.format.printf(({ level, message, timestamp }) => `${timestamp} ${level}: ${message}`) ) }) ] }); logger.info('Server started');
Look at the format used in the Console transport.
The logger uses a timestamp and printf format, so the output includes the ISO timestamp, the log level, and the message.
Choose the correct Pino logger configuration snippet to enable pretty printing (human-readable logs) in a NestJS application.
Check the latest Pino documentation for pretty printing options.
Since Pino v7, pretty printing is enabled via the transport option with target: 'pino-pretty'.
Consider this Winston logger setup in NestJS. Why does calling logger.info('Failure') produce no output?
import { WinstonModule } from 'nest-winston'; import * as winston from 'winston'; const logger = WinstonModule.createLogger({ transports: [ new winston.transports.Console({ level: 'warn' }) ] }); logger.info('Failure');
Remember the log level priorities: error > warn > info.
Log levels in Winston have priorities (lower number = higher priority): 'error'(0) > 'warn'(1) > 'info'(2). With transport level 'warn', only 'warn' and 'error' log, not 'info'.
Arrange these steps in the correct order to add Pino logging to a NestJS application.
Think about installation before usage.
You first install packages, then import the module, configure it, and finally use the logger service.
Choose the best practice to improve logging performance in a production NestJS app using Pino.
Think about how to reduce blocking operations in production.
Asynchronous logging offloads log writing to a separate process, reducing app blocking and improving performance.