0
0
NestJSframework~10 mins

Logging with Winston or Pino in NestJS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Winston logger in a NestJS service.

NestJS
import { Logger } from '[1]';
Drag options to blanks, or click blank then click option'
Apino
Bexpress
Cnestjs/common
Dwinston
Attempts:
3 left
💡 Hint
Common Mistakes
Importing from 'nestjs/common' instead of 'winston'.
Confusing Winston with Pino or Express.
2fill in blank
medium

Complete the code to create a Winston logger instance with console transport.

NestJS
const logger = winston.createLogger({ transports: [new winston.transports.[1]()] });
Drag options to blanks, or click blank then click option'
AFile
BHttp
CConsole
DStream
Attempts:
3 left
💡 Hint
Common Mistakes
Using File transport when console output is needed.
Using Http or Stream transports incorrectly.
3fill in blank
hard

Fix the error in the NestJS logger injection code.

NestJS
constructor(private readonly logger: [1]) {}
Drag options to blanks, or click blank then click option'
ALogger
BConsoleLogger
CWinstonLogger
DLoggerService
Attempts:
3 left
💡 Hint
Common Mistakes
Using LoggerService instead of Logger class.
Using WinstonLogger which is not a NestJS injectable class.
4fill in blank
hard

Fill both blanks to configure Pino logger with pretty print and level 'debug'.

NestJS
const logger = pino({ level: '[1]', transport: { target: '[2]' } });
Drag options to blanks, or click blank then click option'
Adebug
Binfo
Cpino-pretty
Dpino-http
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'info' level instead of 'debug' for detailed logs.
Using 'pino-http' which is for HTTP logging middleware.
5fill in blank
hard

Fill all three blanks to create a Winston logger with JSON format, timestamp, and console transport.

NestJS
const logger = winston.createLogger({ format: winston.format.combine(winston.format.[2](), winston.format.[1]()), transports: [new winston.transports.[3]()] });
Drag options to blanks, or click blank then click option'
Ajson
Btimestamp
CConsole
Dcolorize
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'colorize' instead of 'json' for format.
Using 'File' transport instead of 'Console' for terminal output.