Complete the code to import the popular logging library 'winston'.
const winston = require('[1]');
The 'winston' library is used for logging in Node.js. Importing it correctly allows us to create loggers.
Complete the code to create a new logger with JSON format output.
const logger = winston.createLogger({ format: winston.format.[1]() });The 'json' format outputs logs as structured JSON, which is easy to parse and analyze.
Fix the error in the code to log an info message with the logger.
logger.[1]('Server started successfully');
The 'info' method is used to log informational messages in winston.
Fill both blanks to add a timestamp and format the log as JSON.
const logger = winston.createLogger({ format: winston.format.combine(winston.format.[1](), winston.format.[2]()) });Combining 'timestamp' and 'json' formats adds a time field and outputs logs as JSON.
Fill all three blanks to create a logger that writes JSON logs with timestamps to a file named 'app.log'.
const logger = winston.createLogger({ format: winston.format.combine(winston.format.[1](), winston.format.[2]()), transports: [new winston.transports.[3]({ filename: 'app.log' })] });This logger adds timestamps, formats logs as JSON, and writes them to a file named 'app.log' using the File transport.