

# SetBucketLoggingStatus（SOAP API）
<a name="SOAPSetBucketLoggingStatus"></a>

**注意**  
 Amazon S3 的 SOAP API 不适用于新客户，并将于 2025 年 8 月 31 日接近使用寿命终止（EOL）。我们建议您使用 REST API 或 Amazon SDK。

 `SetBucketLoggingStatus` 操作更新现有存储桶的日志记录状态。

 有关此功能的一般介绍，请参阅[服务器日志](https://docs.amazonaws.cn/AmazonS3/latest/userguide/ServerLogs.html)。

**Example**  
此示例请求对“mybucket”存储桶启用服务器访问日志记录，并将日志配置为传输到前缀“access\_log-”下的“mylogs”  
`Sample Request`  

```
 1. <?xml version="1.0" encoding="utf-8"?>
 2.     <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 3.     <soap:Body>
 4.     <SetBucketLoggingStatus xmlns="https://doc.s3.amazonaws.com/2006-03-01">
 5.       <Bucket>myBucket</Bucket>
 6.       <AWSAccessKeyId>{{YOUR_AWS_ACCESS_KEY_ID}}</AWSAccessKeyId>
 7.       <Timestamp>2006-03-01T12:00:00.183Z</Timestamp>
 8.       <Signature>{{YOUR_SIGNATURE_HERE}}</Signature>
 9.       <BucketLoggingStatus>
10.         <LoggingEnabled>
11.           <TargetBucket>mylogs</TargetBucket>
12.           <TargetPrefix>mybucket-access_log-</TargetPrefix>
13.         </LoggingEnabled>
14.       </BucketLoggingStatus>
15.     </SetBucketLoggingStatus>
16.     </soap:Body>
17.     :</soap:Envelope>
```
`Sample Response`  

```
1. <?xml version="1.0" encoding="utf-8"?>
2.     <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
3.       <soapenv:Header>
4.       </soapenv:Header>
5.       <soapenv:Body>
6.         <SetBucketLoggingStatusResponse xmlns="https://s3.amazonaws.com/doc/2006-03-01"/>
7.       </soapenv:Body>
8.     </soapenv:Envelope>
```

## 访问控制
<a name="SOAPSetBucketLoggingStatusAccessControl"></a>

仅允许存储桶的拥有者调用此操作。