import logging FORMAT = '[%(asctime)-15s] [%(levelname)s:%(lineno)d] %(message)s' logging.basicConfig(format=FORMAT, level=logging.INFO) logger = logging.getLogger('example') logger.debug("This is a debug message what won't be seen with level=logging.INFO") logger.info("This is an info message that will be seen") logger.error("This is an error message that will be seen") logger.critical("This is a critical message that will be seen") try: foo except Exception, ex: logger.exception("This is an exception log") logger.setLevel(logging.DEBUG) logger.debug('Now you can see debug messages')}
CategoryComputing.Lang.Python - Logging