import logging logging.basicConfig(level=logging.INFO) log = logging.getLogger("test") log.debug("Test message: %d(%s)", 100, "foobar") log.info("Test message2: %d(%s)", 100, "foobar") log.warning("Test message3: %d(%s)") log.error("Test message4") log.critical("Test message5") logging.info("Test message6") try: 1/0 except: log.exception("Some trouble (%s)", "expected")