logging Module

noun

say it: “LOG-ing MOJ-ool” /ˈlɒɡɪŋ ˈmɒdʒuːl/

Python's standard module that records what a program does, with a level for how serious each message is; unlike print(), messages can be turned off or sent to a file.

What is the logging module?

The logging module records what your program is doing, with a level for how serious each message is. Unlike print(), you can turn messages on or off and send them to a file.

import logging
logging.basicConfig(level=logging.INFO)
logging.info("Order 1042 placed")
logging.warning("Stock running low")

In a sentence

  • “The logging module wrote "Order 1042 placed" to the log at INFO level.”
  • “Switching to the logging module let the scheduled job write to a file instead of the screen.”

Level: Journeyman · More Python terms at this level

Updated