API | 操作名 | 操作描述 |
设置日志管理 | 为源存储桶开启日志记录 | |
查询日志管理 | 查询源存储桶的日志配置信息 |
try{// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000";PutBucketLoggingRequest request = new PutBucketLoggingRequest(bucket);// 设置保存日志的目标路径request.SetTarget("targetbucket-1250000000", "logs/");//执行请求PutBucketLoggingResult result = cosXml.PutBucketLogging(request);//请求成功Console.WriteLine(result.GetResultInfo());}catch (COSXML.CosException.CosClientException clientEx){//请求失败Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){//请求失败Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
try{// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000";GetBucketLoggingRequest request = new GetBucketLoggingRequest(bucket);//执行请求GetBucketLoggingResult getResult = cosXml.GetBucketLogging(request);//请求成功BucketLoggingStatus status = getResult.bucketLoggingStatus;if (status != null && status.loggingEnabled != null) {string targetBucket = status.loggingEnabled.targetBucket;string targetPrefix = status.loggingEnabled.targetPrefix;}}catch (COSXML.CosException.CosClientException clientEx){//请求失败Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){//请求失败Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
本页内容是否解决了您的问题?