#!/usr/bin/env python #coding=utf-8 #導(dǎo)入Python標(biāo)準(zhǔn)日志模塊 import logging #從Python SDK導(dǎo)入BOS配置管理模塊以及安全認(rèn)證模塊 from baidubce.bce_client_configuration import BceClientConfiguration from baidubce.auth.bce_credentials import BceCredentials #設(shè)置BosClient的Host,Access Key ID和Secret Access Key bos_host = "bj.bcebos.com" access_key_id = AK secret_access_key = SK #設(shè)置日志文件的句柄和日志級(jí)別 logger = logging.getLogger('baidubce.http.bce_http_client') fh = logging.FileHandler("sample.log") fh.setLevel(logging.DEBUG) #設(shè)置日志文件輸出的順序、結(jié)構(gòu)和內(nèi)容 formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) logger.setLevel(logging.DEBUG) logger.addHandler(fh) #創(chuàng)建BceClientConfiguration config = BceClientConfiguration(credentials=BceCredentials(access_key_id, secret_access_key), endpoint = bos_host) |
|