import logging # 设置日志基础样式 logging.basicConfig(level=logging.INFO, format='levelname:%(levelname)s filename: %(filename)s ' 'outputNumber: [%(lineno)d] thread: %(threadName)s output msg: %(message)s' ' - %(asctime)s', datefmt='[%d/%b/%Y %H:%M:%S]', filename='./loggmsg.log') logger = logging.getLogger(__name__) if __name__ == "__main__": logger.info('logging info')