import logging logging.basicConfig(level=logging.WARNING) logger = logging.getLogger(__name__) logger.warning("This is a warning message")
import logging logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) logger.debug("Starting program...") # do some work here logger.debug("Program finished.")This code snippet sets the logging level to DEBUG, which means that all messages of severity DEBUG or higher will be logged. The logger object is used to log messages, in this case, to describe the program's behavior. The LOGGER package belongs to the Python Standard Library, which means it is included with every Python installation. Therefore, no external packages or libraries need to be installed to use the LOGGER module.