API | 操作名 | 操作描述 |
设置日志管理 | 为源存储桶开启日志记录 | |
查询日志管理 | 查询源存储桶的日志配置信息 |
QCloudPutBucketLoggingRequest *request = [QCloudPutBucketLoggingRequest new];// 说明日志记录配置的状态,如果无子节点信息则意为关闭日志记录QCloudBucketLoggingStatus *status = [QCloudBucketLoggingStatus new];// 存储桶 logging 设置的具体信息,主要是目标存储桶QCloudLoggingEnabled *loggingEnabled = [QCloudLoggingEnabled new];// 存放日志的目标存储桶,可以是同一个存储桶(但不推荐),或同一账户下、同一地域的存储桶loggingEnabled.targetBucket = @"examplebucket-1250000000";// 日志存放在目标存储桶的指定路径loggingEnabled.targetPrefix = @"mylogs";status.loggingEnabled = loggingEnabled;request.bucketLoggingStatus = status;// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";[request setFinishBlock:^(id outputObject, NSError *error) {// outputObject 包含所有的响应 http 头部NSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] PutBucketLogging:request];
let req = QCloudPutBucketLoggingRequest.init();// 说明日志记录配置的状态,如果无子节点信息则意为关闭日志记录let status = QCloudBucketLoggingStatus.init();// 存储桶 logging 设置的具体信息,主要是目标存储桶let loggingEnabled = QCloudLoggingEnabled.init();// 存放日志的目标存储桶,可以是同一个存储桶(但不推荐),或同一账户下、同一地域的存储桶// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketloggingEnabled.targetBucket = "examplebucket-1250000000";// 日志存放在目标存储桶的指定路径loggingEnabled.targetPrefix = "logs/";status.loggingEnabled = loggingEnabled;req.bucketLoggingStatus = status;// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketreq.bucket = "examplebucket-1250000000";req.finishBlock = {(result,error) inif let result = result {// result 包含响应的 header 信息} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().putBucketLogging(req);
QCloudGetBucketLoggingRequest *getReq = [QCloudGetBucketLoggingRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketgetReq.bucket = @"examplebucket-1250000000";[getReq setFinishBlock:^(QCloudBucketLoggingStatus * _Nonnull result,NSError * _Nonnull error) {// 日志配置信息QCloudLoggingEnabled *loggingEnabled = result.loggingEnabled;}];[[QCloudCOSXMLService defaultCOSXML]GetBucketLogging:getReq];
let req = QCloudGetBucketLoggingRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketreq.bucket = "examplebucket-1250000000";req.setFinish { (result, error) inif let result = result {// 日志配置信息let enabled = result.loggingEnabled} else {print(error!);}};QCloudCOSXMLService.defaultCOSXML().getBucketLogging(req);
本页内容是否解决了您的问题?