标签:ace info com icc http name config filename file
一、logging基本https://www.cnblogs.com/huaizhi/p/11245246.html
import logging
logging.basicConfig() ---默认项
logging.debug(‘This is a debug message‘)
logging.info(‘This is an info message‘)
logging.warning(‘This is a warning message‘)
logging.error(‘This is an error message‘)
logging.critical(‘This is a critical message‘)
=========== 默认配置项,只会打印warning级别以及以上级别
WARNING:root:This is a warning message
ERROR:root:This is an error message
CRITICAL:root:This is a critical message
添加参数后:
import logging logging.basicConfig(filename=‘log.text‘, filemode=‘w‘, format="%(asctime)s %(name)s %(levelname)s:%(message)s", datefmt=‘%d-%M-%Y %H:%M:%S‘, level=logging.INFO) --指定了文件后,就不会再控制台打印,会直接存到指定文件中 logging.debug(‘This is a debug message‘) logging.info(‘This is an info message‘) logging.warning(‘This is a warning message‘) logging.error(‘This is an error message‘) logging.critical(‘This is a critical message‘) try: print(5 / 0) except Exception as e: logging.exception(‘occurred‘) --可以打印出具体的问题。
1.实现一个py文件一个日志,且日志大于5M自动覆盖https://www.cnblogs.com/yfacesclub/p/9001073.html
2.
标签:ace info com icc http name config filename file
原文地址:https://www.cnblogs.com/tarzen213/p/12079043.html