API | 操作名 | 操作描述 |
设置日志管理 | 为源存储桶开启日志记录 | |
查询日志管理 | 查询源存储桶的日志配置信息 |
String srcBucket = "examplebucket-1250000000"; //格式:BucketName-APPIDString targetBucket = "examplebucket-1250000000"; //格式:BucketName-APPIDPutBucketLoggingRequest putBucketLoggingRequest =new PutBucketLoggingRequest(srcBucket);// 目标存储桶putBucketLoggingRequest.setTargetBucket(targetBucket);// 日志存储的指定位置putBucketLoggingRequest.setTargetPrefix("dir/");cosXmlService.putBucketLoggingAsync(putBucketLoggingRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {PutBucketLoggingResult putBucketLoggingResult =(PutBucketLoggingResult) result;}// 如果您使用 kotlin 语言来调用,请注意回调方法中的异常是可空的,否则不会回调 onFail 方法,即:// clientException 的类型为 CosXmlClientException?,serviceException 的类型为 CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
// 存储桶名称,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称。 https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";GetBucketLoggingRequest getBucketLoggingRequest =new GetBucketLoggingRequest(bucket);cosXmlService.getBucketLoggingAsync(getBucketLoggingRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {GetBucketLoggingResult getBucketLoggingResult =(GetBucketLoggingResult) result;}// 如果您使用 kotlin 语言来调用,请注意回调方法中的异常是可空的,否则不会回调 onFail 方法,即:// clientException 的类型为 CosXmlClientException?,serviceException 的类型为 CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
本页内容是否解决了您的问题?