新聞中心
這里有您想知道的互聯網營銷解決方案
創(chuàng)新互聯Python教程:python logging日志的禁用
禁用說明

1、在需要禁用日志的地方插入logging.disable(logging.logging_level)即可。
2、禁用的級別一定要對應代碼中寫的那個級別對應。
后面的logging對應的loggle_level函數都會失效。
實例
n = 0
try:
print(10 / n)
except Exception as e:
print('e:',e)
logging.error(e)
logger.error("發(fā)生錯誤1")
logging.disable(logging.ERROR)
logger.error("發(fā)生錯誤2")--------------查看日志文件----------- 2018-08-02 15:48:09,237 - root - ERROR - 24 - division by zero 2018-08-02 15:48:09,237 - root - ERROR - 25 - 發(fā)生錯誤
以上就是python logging日志的禁用方法,希望對大家有所幫助。更多Python學習指路:創(chuàng)新互聯python教程
本文教程操作環(huán)境:windows7系統、Python 3.9.1,DELL G3電腦。
網站標題:創(chuàng)新互聯Python教程:python logging日志的禁用
本文路徑:http://m.5511xx.com/article/dpsheeo.html


咨詢
建站咨詢
