Want everyone on your software team to learn this? Free 14-day trial.
Train my teamObservabilityimport logging
# Will print "WARNING:root:Watch out!" to the console.
logging.warning("Watch out!")
# Configure the logs to include the time and date.
logging.basicConfig(
format = "%(asctime)s %(levelname)s:%(message)s",
level = logging.DEBUG,
force = True
)
# Will prefix a timestamp with format "2010-12-12 11:41:42,612" to the log.
logging.info("Info message")