Bird
0
0

Which of the following is the correct way to configure logging to write to a file named app.log with level WARNING in Flask?

easy📝 Syntax Q12 of 15
Flask - Deployment
Which of the following is the correct way to configure logging to write to a file named app.log with level WARNING in Flask?
Alogging.basicConfig(filename='app.log', level=logging.WARNING)
Blogging.setup(filename='app.log', level='WARNING')
Capp.logger.config(filename='app.log', level=logging.WARNING)
Dlogging.fileConfig('app.log', level=logging.WARNING)
Step-by-Step Solution
Solution:
  1. Step 1: Recall logging setup syntax

    Use logging.basicConfig() with filename and level parameters.
  2. Step 2: Check each option

    Only logging.basicConfig(filename='app.log', level=logging.WARNING) uses correct function and parameters.
  3. Final Answer:

    logging.basicConfig(filename='app.log', level=logging.WARNING) -> Option A
  4. Quick Check:

    basicConfig sets file and level [OK]
Quick Trick: Use logging.basicConfig() to set file and level [OK]
Common Mistakes:
MISTAKES
  • Using wrong function names like setup or fileConfig
  • Passing level as string instead of logging constant
  • Trying to configure app.logger directly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes