一.教程
import logging
logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s
- %(message)s')
#filename='myProgramLog.txt' 可以指定输入文件
logging.debug('Some debugging details.')
#发送日志
logging.disable(logging.CRITICAL)
#禁止
二.实例
import logging
logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s- %(message)s')
logging.debug('Start of program')
def factorial(n):
logging.debug('Start of factorial(%s%%)'
%
(n))
total =
1
-
for i in range(1, n 1):
total = total * i
logging.debug('i is '
str(i)
', total is '
str(total))
logging.debug('End of factorial(%s%%)'
%
(n))
-
return total
print(factorial(7))
logging.debug('End of program')