Bird
0
0

How can you ensure your Flask production logs include timestamps and log levels in each entry?

hard📝 Application Q9 of 15
Flask - Deployment
How can you ensure your Flask production logs include timestamps and log levels in each entry?
AEnable Flask debug mode to add timestamps automatically
BUse app.logger.setLevel(logging.INFO) only
CWrite timestamps manually in each log message
DSet a logging Formatter with a format string including %(asctime)s and %(levelname)s
Step-by-Step Solution
Solution:
  1. Step 1: Know how to customize log message format

    Logging Formatter controls the output format of log entries.
  2. Step 2: Use format string with timestamp and level

    Include %(asctime)s for time and %(levelname)s for log level in Formatter.
  3. Final Answer:

    Set a logging Formatter with a format string including %(asctime)s and %(levelname)s -> Option D
  4. Quick Check:

    Formatter adds timestamps and levels to logs [OK]
Quick Trick: Use Formatter with %(asctime)s and %(levelname)s for detailed logs [OK]
Common Mistakes:
MISTAKES
  • Relying on setLevel to add timestamps
  • Manually adding timestamps in code
  • Thinking debug mode adds timestamps automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes