Lesson 34 of 55 · Python
Logging
Duration: 20 minutes
Lesson 34 of 55 · Python
Duration: 20 minutes
print() statements, use the logging module for flexible, configurable output.\n\npython\nimport logging\n\nlogging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')\n\nlogging.debug('Debug message') # Not shown at INFO level\nlogging.info('Info message')\nlogging.warning('Warning message')\n\n\nYou can direct logs to the console, files, rotate them, and adjust verbosity on the fly—essential for production‑grade applications.\n