use of com.qcloud.cos.model.BucketLoggingConfiguration in project cos-java-sdk-v5 by tencentyun.
the class BucketDemo method SetBucketLogging.
// 开启日志存储
public static void SetBucketLogging() {
// 1 初始化用户身份信息(appid, secretId, secretKey)
COSCredentials cred = new BasicCOSCredentials("AKIDXXXXXXXX", "1A2Z3YYYYYYYYYY");
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
ClientConfig clientConfig = new ClientConfig(new Region("ap-beijing-1"));
// 3 生成cos客户端
COSClient cosclient = new COSClient(cred, clientConfig);
// bucket名称, 需包含appid
String bucketName = "examplebucket-1251668577";
BucketLoggingConfiguration bucketLoggingConfiguration = new BucketLoggingConfiguration();
// 设置日志存储的 bucket
bucketLoggingConfiguration.setDestinationBucketName(bucketName);
// 设置日志存储的前缀
bucketLoggingConfiguration.setLogFilePrefix("logs/");
SetBucketLoggingConfigurationRequest setBucketLoggingConfigurationRequest = new SetBucketLoggingConfigurationRequest(bucketName, bucketLoggingConfiguration);
cosclient.setBucketLoggingConfiguration(setBucketLoggingConfigurationRequest);
}
Aggregations