34 lines
885 B
Python
34 lines
885 B
Python
|
||
#引入标准日志模块
|
||
import logging
|
||
|
||
#引入配置管理模块以及安全认证模块
|
||
from baidubce.bce_client_configuration import BceClientConfiguration
|
||
from baidubce.auth.bce_credentials import BceCredentials
|
||
|
||
#设置Host,Access Key ID和Secret Access Key
|
||
HOST = 'iam.bj.baidubce.com'
|
||
AK = 'ALTAKPk92fX9cgGDax83yNL8mP'
|
||
SK = '9b16b8efd4dc463d8bbd5462db1db8a5'
|
||
|
||
#设置日志文件的句柄和日志级别
|
||
logger = logging.getLogger('baidubce.services.iam.iamclient')
|
||
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)
|
||
|
||
#创建BceClientConfiguration
|
||
config = BceClientConfiguration(credentials=BceCredentials(AK, SK), endpoint=HOST)
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|