logging
def logging1():
"""
logging 1 test
:return:
"""
logging.info('this is logging 1')
def logging2():
"""
logging 1 test
:return:
"""
logging.info('this is logging 2')
def logging_test():
"""
logging 1 test
:return:
"""
logging.basicConfig(filename='logging_test.log', filemode='w',
format='%(name)s - %(levelname)s - %(asctime)s - %(message)s', level=logging.INFO)
logging.info('this is logging main')
logging.warning('this is warning main')
logging.debug('this is logging debug')
logging.error('this is logging error')
logging.critical('this is logging critical')
logging1()
logging2()
输出:
root - INFO - 2023-05-09 14:59:21,414 - this is logging main
root - WARNING - 2023-05-09 14:59:21,414 - this is warning main
root - ERROR - 2023-05-09 14:59:21,414 - this is logging error
root - CRITICAL - 2023-05-09 14:59:21,414 - this is logging critical
root - INFO - 2023-05-09 14:59:21,414 - this is logging 1
root - INFO - 2023-05-09 14:59:21,414 - this is logging 2
参考:
[1] https://blog.csdn.net/qq_27262673/article/details/126844808