S3 enable bucket logging
Enables bucket logging for a bucket. Use this operation to configure the target log bucket, prefix, and logging type (Standard or Journal).
Syntax
PUT /_BUCKET_?logging HTTP/1.1
Request entities
Parameters are XML-encoded in the body of the request, in the following format:
<BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<LoggingEnabled>
<TargetBucket>string</TargetBucket>
<TargetGrants>
<Grant>
<Grantee>
<DisplayName>string</DisplayName>
<EmailAddress>string</EmailAddress>
<ID>string</ID>
<xsi:type>string</xsi:type>
<URI>string</URI>
</Grantee>
<Permission>string</Permission>
</Grant>
</TargetGrants>
<TargetObjectKeyFormat>
<PartitionedPrefix>
<PartitionDateSource>DeliveryTime|EventTime</PartitionDateSource>
</PartitionedPrefix>
<SimplePrefix/>
</TargetObjectKeyFormat>
<TargetPrefix>string</TargetPrefix>
<LoggingType>Standard|Journal</LoggingType>
<ObjectRollTime>integer</ObjectRollTime>
<Filter>
<S3Key>
<FilterRule>
<Name>suffix/prefix/regex</Name>
<Value></Value>
</FilterRule>
</S3Key>
</Filter>
</LoggingEnabled>
</BucketLoggingStatus>
Request Parameters
Following table lists the request parameters:
| Name | Type | Description | Required |
|---|---|---|---|
| BucketLoggingStatus | Container | Enables or disables logging configuration for the bucket. | Yes |
| LoggingEnabled | Container | Contains the logging configuration details for the bucket. | Yes |
| TargetBucket | String | Specifies the log bucket where access logs are stored. The log bucket cannot have its own logging enabled. | Yes |
| TargetGrants | Container | Not supported. The log bucket owner is automatically the owner of the log objects. | No |
| TargetObjectKeyFormat | Container | Defines the format of the log object key. Can include PartitionedPrefix or SimplePrefix. |
No |
| PartitionedPrefix | Container | Indicates a partitioned log object key format. The PartitionDateSource field is fixed as DeliveryTime. |
No |
| SimplePrefix | Container | Indicates a simple (default) log object key format. | No |
| TargetPrefix | String | Prefix used for log object names. Useful to distinguish logs from multiple source buckets. | No |
| LoggingType | String | Logging mode. Valid values: Standard (default) or Journal. Journal mode logs operations before completion. |
No |
| ObjectRollTime | Integer | Time in seconds after which a new log object is created. Default: 3600 (1 hour). | No |
| Filter | Container | Optional filter for selecting log entries based on object key or metadata. | No |
Response entities
The response is XML encoded in the body of the request, only if a configuration change triggers flushing of the current logging object. In this case it will return the name of the flushed logging object in following format:
<PostBucketLoggingOutput xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<FlushedLoggingObject>string</FlushedLoggingObject>
</PostBucketLoggingOutput>
HTTP Response
The following HTTP response might be returned:
HTTP Response
400
- Status Code
-
MalformedXML - Description
-
The XML is not well-formed.
HTTP Response
400
- Status Code
-
InvalidArgument - Description
-
Missing mandatory value or invalid value.
HTTP Response
404
- Status Code
-
NoSuchBucket - Description
-
The bucket does not exist.