Bird
0
0

You want to log both errors to a file and info messages to the console in your Flask app. Which setup achieves this?

hard📝 Workflow Q8 of 15
Flask - Deployment
You want to log both errors to a file and info messages to the console in your Flask app. Which setup achieves this?
AAdd a FileHandler with level INFO and a StreamHandler with level ERROR to app.logger
BAdd only a StreamHandler with level ERROR to app.logger
CAdd only a FileHandler with level INFO to app.logger
DAdd a FileHandler with level ERROR and a StreamHandler with level INFO to app.logger
Step-by-Step Solution
Solution:
  1. Step 1: Understand handler roles and levels

    FileHandler writes to file, StreamHandler outputs to console.
  2. Step 2: Match levels to desired log types

    FileHandler at ERROR logs errors; StreamHandler at INFO logs info and above.
  3. Final Answer:

    Add a FileHandler with level ERROR and a StreamHandler with level INFO to app.logger -> Option D
  4. Quick Check:

    Separate handlers with correct levels log to file and console [OK]
Quick Trick: Use different handlers with levels for file and console logging [OK]
Common Mistakes:
MISTAKES
  • Swapping levels between handlers
  • Using only one handler for both outputs
  • Setting levels that block desired messages

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes