Baidu AI Cloud
中国站

百度智能云

Object Storage

PutBucketLogging

Interface Description

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

Request

  • Request syntax

    PUT /?logging HTTP/1.1
    Host: <BucketName>.bj.bcebos.com
    Date: <Date>
    Authorization: <AuthorizationString>
    Content-Length: <ContentLength>
    
    {
       "targetBucket": "TargetBucketName",
       "targetPrefix": "TargetPrefixName"
    }
  • Request header field

    No special parameters.

  • Request parameters

    Name Description Type Required?
    targetBucket It specifies the logging storage bucket. String Yes
    targetPrefix It specifies the log file prefix saved finally. String No. It is recommended to enter this field to distinguish the access log.

Response

  • Response element

    No special element

  • Response header field

    No special header field.

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 targetPrefix 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.
  • targetPrefix indicates the object name prefix for storing the logging, which can be empty. If it is not empty, targetPrefix can contain letters, numbers, hyphen, underline and slash, and it must start with a letter, with a length no more than 32 bits.
  • The repeated requests return the same results.

Example

  • Request example

    PUT /?logging HTTP/1.1
    Host: BucketName.bj.bcebos.com
    Date: Tue, 17 May 2016 08:36:52 GMT
    Authorization: AuthorizationString
    Content-Length: 55
    
    {
    	"targetBucket": "dscbucket",
    	"targetPrefix": "mylog/"
    }
  • Response example

    HTTP/1.1 200 OK
    x-bce-request-id: 1a5fd81e-626b-45b3-a885-15fff9cd106c
    Date: Tue, 17 May 2016 08:36:52 GMT
    Content-Length: 0
    Server: BceBos
Previous
Lifecycle
Next
Payment by Requester