Bird
0
0

What will happen if you call logger.error("Error happened") without exc_info=True inside an exception block?

medium📝 Command Output Q5 of 15
FastAPI - Error Handling
What will happen if you call logger.error("Error happened") without exc_info=True inside an exception block?
AThe program crashes
BThe error message and traceback are logged automatically
CNo message is logged
DOnly the error message is logged without traceback
Step-by-Step Solution
Solution:
  1. Step 1: Understand exc_info parameter

    exc_info=True tells logger to include exception traceback details.
  2. Step 2: Effect of missing exc_info

    Without exc_info=True, only the error message logs, no traceback.
  3. Final Answer:

    Only the error message is logged without traceback -> Option D
  4. Quick Check:

    exc_info missing = no traceback in logs [OK]
Quick Trick: Add exc_info=True to log error tracebacks [OK]
Common Mistakes:
MISTAKES
  • Assuming traceback logs without exc_info
  • Thinking no log happens without exc_info
  • Believing program crashes on logging

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FastAPI Quizzes