python log使用
import os
import json
import logging.config
import logging
logging.basicConfig(filename = 'C:\\Users\\user\\Desktop\\log.txt',
level = logging.DEBUG,
filemode = 'w',
format = '%(asctime)s - %(levelname)s: %(message)s'
)
logger = logging.getLogger('root')
import json
import logging.config
import logging
logging.basicConfig(filename = 'C:\\Users\\user\\Desktop\\log.txt',
level = logging.DEBUG,
filemode = 'w',
format = '%(asctime)s - %(levelname)s: %(message)s'
)
logger = logging.getLogger('root')
logger.info('info ***')
logger.error('error ***')
python log的级别
级别对应的值:
CRITICAL 50
ERROR 40
WARNING 30
INFO 20
DEBUG 10
NOTSET 0
低于级别的log将被忽略