API | Operation | Description |
Setting logging | Enables logging for a source bucket | |
Querying logging configuration | Queries the logging configuration of a source bucket |
QCloudPutBucketLoggingRequest *request = [QCloudPutBucketLoggingRequest new];// Status of the logging configuration. If there is no subnode information, logging is disabledQCloudBucketLoggingStatus *status = [QCloudBucketLoggingStatus new];// Specific logging configuration; this mainly refers to the destination bucketQCloudLoggingEnabled *loggingEnabled = [QCloudLoggingEnabled new];// Destination bucket for storing logs; this can be the source bucket (not recommended) or a bucket in the same region under the same accountloggingEnabled.targetBucket = @"examplebucket-1250000000";// Specified path in the destination bucket for storing logsloggingEnabled.targetPrefix = @"mylogs";status.loggingEnabled = loggingEnabled;request.bucketLoggingStatus = status;// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";[request setFinishBlock:^(id outputObject, NSError *error) {// `outputObject` contains all the HTTP response headersNSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] PutBucketLogging:request];
let req = QCloudPutBucketLoggingRequest.init();// Status of the logging configuration. If there is no subnode information, logging is disabledlet status = QCloudBucketLoggingStatus.init();// Specific logging configuration; this mainly refers to the destination bucketlet loggingEnabled = QCloudLoggingEnabled.init();// Destination bucket for storing logs; this can be the source bucket (not recommended) or a bucket in the same region under the same account// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketloggingEnabled.targetBucket = "examplebucket-1250000000";// Specified path in the destination bucket for storing logsloggingEnabled.targetPrefix = "logs/";status.loggingEnabled = loggingEnabled;req.bucketLoggingStatus = status;// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketreq.bucket = "examplebucket-1250000000";req.finishBlock = {(result,error) inif let result = result {// "result" contains response headers.} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().putBucketLogging(req);
QCloudGetBucketLoggingRequest *getReq = [QCloudGetBucketLoggingRequest new];// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketgetReq.bucket = @"examplebucket-1250000000";[getReq setFinishBlock:^(QCloudBucketLoggingStatus * _Nonnull result,NSError * _Nonnull error) {// Logging configurationQCloudLoggingEnabled *loggingEnabled = result.loggingEnabled;}];[[QCloudCOSXMLService defaultCOSXML]GetBucketLogging:getReq];
let req = QCloudGetBucketLoggingRequest.init();// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketreq.bucket = "examplebucket-1250000000";req.setFinish { (result, error) inif let result = result {// Logging configurationlet enabled = result.loggingEnabled} else {print(error!);}};QCloudCOSXMLService.defaultCOSXML().getBucketLogging(req);
Was this page helpful?