Baidu AI Cloud
中国站

百度智能云

Object Storage

Enable Access Log of Bucket

Interface Description

This interface is used to enable the logging function of the bucket and specify the logging storage bucket and the logging file prefix. For logging rules, see Log Naming Convention and Log Format.

Considerations

  • The user must be the source bucket owner with the FULL_CONTROL permission and the destination bucket owner.
  • The source bucket and the destination bucket must exist at the same time.
  • The source bucket and the destination bucket must be of the same region.
  • If JSON in HTTP Body is invalid, BOS returns “CODE_MALFORMED_JSON”.
  • If JSON in the HTTP Body contains an invalid field, BOS returns “CODE_INAPPROPRIATE_JSON”.
  • Users can save the logging of different source buckets in the same destination bucket. It is recommended to specify different destinationPrefix for distinguishing.
  • If the source bucket enables the logging feature, the corresponding logging information is also deleted when the source bucket is deleted.
  • If the destination bucket of logging is deleted, the logging feature of the source bucket is automatically disabled.
  • If you need to modify the destination bucket information, you can send another PutBucketLogging request, which contains the information to modify.
  • destinationPrefix indicates the object name prefix for storing the logging, which can be empty. If it is not empty, destinationPrefix can contain letters, numbers, hyphen, underlines, and slashes and must start with a letter and have a length no more than 32 bits.
  • The repeated requests return the same results.

Request URI

PUT /v1/{bucketName}/?logging

Parameter Name Parameter Type Required Description Example Value Parameter Position
bucketName String Yes Bucket name xxx "bucketName_example" Path

Request Body Parameters

Instructions for Data Structure of Request Body Field

Parameter name Parameter type Required Description Example value
destinationBucket String Yes Specify the logging storage bucket. TargetBucketName
targetPrefix String No Specify the log file prefix saved finally. TargetPrefixName

Response Body Parameters

None

Request Example

PUT /v1/bucketName_example/?logging
Common Request Header


{
  "targetPrefix" : "TargetPrefixName",
  "targetBucket" : "TargetBucketName"
}

Response Example

None

Error Code

Refer to the universal error code.

Previous
Get Access Log Configuration of Bucket
Next
Static Website