API | Operation | Description |
Setting logging | Enables logging for a source bucket | |
Querying logging configuration | Queries the logging configuration of a source bucket |
try{// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";PutBucketLoggingRequest request = new PutBucketLoggingRequest(bucket);// Set the destination path for storing logsrequest.SetTarget("targetbucket-1250000000", "logs/");// Execute the requestPutBucketLoggingResult result = cosXml.PutBucketLogging(request);// Request succeededConsole.WriteLine(result.GetResultInfo());}catch (COSXML.CosException.CosClientException clientEx){// Request failedConsole.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){// Request failedConsole.WriteLine("CosServerException: " + serverEx.GetInfo());}
try{// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";GetBucketLoggingRequest request = new GetBucketLoggingRequest(bucket);// Execute the requestGetBucketLoggingResult getResult = cosXml.GetBucketLogging(request);// Request succeededBucketLoggingStatus status = getResult.bucketLoggingStatus;if (status != null && status.loggingEnabled != null) {string targetBucket = status.loggingEnabled.targetBucket;string targetPrefix = status.loggingEnabled.targetPrefix;}}catch (COSXML.CosException.CosClientException clientEx){// Request failedConsole.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){// Request failedConsole.WriteLine("CosServerException: " + serverEx.GetInfo());}
Was this page helpful?