QuizzesLogging — Beyond print() — Concept Check
intermediate
python

Logging — Beyond print() — Concept Check

Questions on Logging — Beyond print(). The logging module gives leveled, timestamped, routable logs — DEBUG/INFO/WARNING/ERROR/CRITICAL — configured once and used via module-level loggers; print() is for humans, logging is for systems.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on Logging — Beyond print() — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.Your application logs are cluttered with DEBUG messages in production. What is the best way to resolve this?

    • AChange the logger level to INFO or higher in production.
    • BManually filter out DEBUG logs before deployment.
    • CRemove all DEBUG log statements from the code.
    • DUse print() instead of logging for DEBUG messages.
  2. 2.A developer uses `logger.exception()` outside of an except block. What is the expected outcome?

    • AIt logs nothing since no exception occurred.
    • BIt logs the message with a fake traceback.
    • CIt logs the message without a traceback.
    • DIt raises an error due to misuse.
  3. 3.You notice that your logs are missing timestamps. What might be the cause?

    • AThe logging format does not include timestamps.
    • BThe basicConfig is missing.
    • CThe logger is not named properly.
    • DThe logger level is set too high.
  4. 4.In a multi-module application, how should loggers be configured?

    • AConfigure each logger separately in every module.
    • BUse a named logger per module and configure once at startup.
    • CAvoid using loggers in modules, use print() instead.
    • DUse a single logger for the entire application.
  5. 5.What happens when the RotatingFileHandler reaches its maxBytes limit?

    • AIt stops logging until space is freed.
    • BIt overwrites the existing log file.
    • CIt throws an exception and halts logging.
    • DIt creates a new log file and rotates the old one.
  6. 6.What is the primary advantage of using `logger.info('user %s served in %d ms', user_id, ms)` over f-strings for logging?

    • AIt is more readable than f-strings.
    • BLazy evaluation prevents unnecessary string building.
    • CIt automatically logs at the correct level.
    • DIt supports more complex data types.
  7. 7.Why might an application use both console and file handlers for logging?

    • ATo separate error logs from informational logs.
    • BTo ensure logs are accessible in real-time and archived for future analysis.
    • CTo duplicate logs for redundancy.
    • DTo reduce the load on the file system.