1, logging module
1.1 TypeError: Level not an integer or a valid string: <function info at 0x03559348>
#源代码 """ import logging logging.basicConfig(filename='log.log', format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s', level=logging.info, datefmt='%a, %d %b %Y %H:%M:%S', filemode='w' ) logging.debug('debug message') logging.info('info message') logging.warning('warning message') logging.error('error message') logging.critical('critical message')
The level = logging.info amended as level = logging.INFO; successful execution file is written log.log
Fri, 01 Nov 2019 09:54:17 logging_test.py[line:17] INFO info message Fri, 01 Nov 2019 09:54:17 logging_test.py[line:18] WARNING warning message Fri, 01 Nov 2019 09:54:17 logging_test.py[line:19] ERROR error message Fri, 01 Nov 2019 09:54:17 logging_test.py[line:20] CRITICAL critical message
Summary: To set the level when the level is set to all uppercase logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL