
# 设置桶日志管理配置
#### 功能说明
设置桶的访问日志配置。
#### 方法定义
```
ObsClient.setBucketLogging
```
#### 请求参数
| **字段名**       |||| **类型**                                                                      | **约束**                           | **说明**                                                                                                  |
|:--|---|---|---|:---|:---|:---|
| Bucket        |||| String                                                                      | 必选                               | 桶名。                                                                                                     |
| RequestDate   |||| String 或 Date | 可选                               | 指定请求时间。 说明： 当为String类型时，必须符合ISO8601或RFC822规范。 |
| Agency        |||| String                                                                      | 如果是设置桶日志配置则必选                    | 委托名。                                                                                                    |
| LoggingEnabled |||| Object                                                                      | 可选                               | 日志配置信息。                                                                                                 |
| - | TargetBucket ||| String                                                                      | 必选                               | 生成日志的目标桶。                                                                                               |
| - | TargetPrefix ||| String                                                                      | 必选                               | 在目标桶中生成日志对象的对象名前缀。                                                                                      |
| - | TargetGrants ||| Array                                                                       | 可选                               | 被授权用户权限信息列表。                                                                                            |
| - | - | Grantee || Object                                                                      | 可选                               | 被授权用户。                                                                                                  |
| - | - | - | Type | String                                                                      | 必选                               | 被授权的[用户类型](https://support.huaweicloud.com/api-obs_browserjs_sdk_api_zh/obs_34_0203.html)。              |
| - | - | - | ID   | String                                                                      | 如果Type为"CanonicalUser"则必选，否则必须为空 | 被授权用户的DomainId。                                                                                         |
| - | - | - | URI  | String                                                                      | 如果Type为"Group"则必选，否则必须为空         | 被授权的[用户组](https://support.huaweicloud.com/api-obs_browserjs_sdk_api_zh/obs_34_0202.html)。               |
| - | - | Permission || String                                                                      | 可选                               | 被授予的[权限](https://support.huaweicloud.com/api-obs_browserjs_sdk_api_zh/obs_34_0201.html)。                |
   
#### 返回结果（InterfaceResult）
| **字段名**   | **类型** | **说明**         |
|:---|:---|:---|
| RequestId | String | OBS服务端返回的请求ID。 |
   
#### 代码样例
```
obsClient.setBucketLogging ({
       Bucket : 'bucketname',
       LoggingEnabled:{
              TargetBucket:'targetbucketname',
              TargetPrefix:'prefix',
              TargetGrants:[
                         {Grantee: {Type:'CanonicalUser',ID:'userid'},Permission: obsClient.enums.PermissionRead},
                         {Grantee: {Type:'Group',URI: obsClient.enums.GroupAllUsers},Permission: obsClient.enums.PermissionRead}
              ]
       }
},function (err, result) {
       if(err){
              console.error('Error-->' + err);
       }else{
              if(result.CommonMsg.Status < 300){
                     console.log('RequestId-->' + result.InterfaceResult.RequestId);
              }else{
                     console.log('Code-->' + result.CommonMsg.Code);
                     console.log('Message-->' + result.CommonMsg.Message);
              }
       }
});
```
