Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Logging | Python Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. Python Fundamentals

Lesson 34 of 55

·Python

Logging

20 minutes

Course progress62%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • `logging.debug`, `info`, `warning`, `error`, `critical` correspond to severity levels.
  • Configure handlers to write logs to console, files, or external services.
  • Adjust logging level without changing code (`logging.getLogger().setLevel()`).

Logging

Instead of scattering print() statements, use the logging module for flexible, configurable output.

import logging

logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

logging.debug('Debug message')   # Not shown at INFO level
logging.info('Info message')
logging.warning('Warning message')

You can direct logs to the console, files, rotate them, and adjust verbosity on the fly—essential for production‑grade applications.

Make it stickPractice what you've learned1 quiz · 5 practical tests · Optional activities from Python FundamentalsBrowse activities
Previous lessonUnit Testing with unittestContinue to lesson 35Virtual Environments and pipBack to Python Fundamentals curriculum