Challenge - 5 Problems
Winston Logging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What is the output of this Winston logger configuration?
Given the following Winston logger setup in an Express app, what will be the output when logger.info('Server started') is called?
Express
const winston = require('winston'); const logger = winston.createLogger({ level: 'info', format: winston.format.simple(), transports: [ new winston.transports.Console() ] }); logger.info('Server started');
Attempts:
2 left
💡 Hint
Look at the format used in the logger configuration.
✗ Incorrect
The simple format outputs the log level followed by the message, separated by a colon and space.
🧠 Conceptual
intermediate1:00remaining
Which transport writes logs to a file in Winston?
In Winston, which transport class is used to save logs into a file?
Attempts:
2 left
💡 Hint
Think about the transport that deals with files.
✗ Incorrect
The File transport writes logs to a file on disk.
❓ Troubleshoot
advanced1:30remaining
Why does this Winston logger not output any logs?
Consider this Winston logger setup. Why does calling logger.debug('Debug message') produce no output?
Express
const winston = require('winston'); const logger = winston.createLogger({ level: 'info', transports: [new winston.transports.Console()] }); logger.debug('Debug message');
Attempts:
2 left
💡 Hint
Check the logger's level setting and how it filters messages.
✗ Incorrect
Winston only logs messages at or above the set level. 'debug' is lower than 'info', so it is ignored.
🔀 Workflow
advanced2:00remaining
Order the steps to add a timestamp to Winston logs
Put these steps in the correct order to configure Winston to include timestamps in log messages.
Attempts:
2 left
💡 Hint
Think about how you build the format step by step.
✗ Incorrect
First create the logger, then add timestamp format, then define how to print it, then assign the format.
✅ Best Practice
expert2:00remaining
What is the best practice for handling uncaught exceptions with Winston?
Which option correctly shows how to configure Winston to handle uncaught exceptions and log them to a file?
Attempts:
2 left
💡 Hint
Winston has a built-in way to catch uncaught exceptions.
✗ Incorrect
Winston can handle uncaught exceptions by configuring an exceptions handler with transports like File.