日志
更新时间:2020-10-26
日志配置
1.日志的配置方式如下所示:
import logging
logger = logging.getLogger('baidubce.http.bce_http_client')
fh = logging.FileHandler('sample.log')
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
logger.setLevel(logging.DEBUG)
logger.addHandler(fh)
2.日志的使用示例如下所示:
import logging
logging.basicConfig(level=logging.DEBUG)
__logger = logging.getLogger(__name__)