You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
Log Storage
PutBucketLogging
Copy page
Download PDF
PutBucketLogging

Function description

This interface is used to enable or disable the log storage feature.

Precautions

Currently, only Beijing and Shanghai support the log storage feature.

Request syntax

PUT /?logging HTTP/1.1 
Host: bucketname.tos-cn-beijing.volces.com 
Authorization: authorization string 
Date: Fri, 30 Jul 2021 06:45:39 GMT 
{ 
  "LoggingEnabled": { 
    "TargetBucket": "test", 
    "TargetPrefix": "prefix", 
    "Role": "ServiceRoleforTOSLogging" 
  } 
}

Request parameters and headers

This request uses the common request message headers; see Common parameters.

NameLocationTypeRequiredSample ValueDescription
loggingQueryStringYes-A special identifier representing the PutBucketLogging request.

Request body elements

tip

If the PutBucketLogging interface is called to disable log storage, configure the request element as
{}.

NameTypeRequiredSample ValueDescription
LoggingEnabledContainerNo-Configuration rules for enabling the log storage feature.
TargetBucketStringNotestThe target storage bucket for storing log files.

TargetPrefix

String

No

tos-accesslog

The log files' storage path in the target bucket.
For example, if TargetPrefix is set to tos-accesslog, the log files will be stored under the path tos-accesslog/SourceBucket/YYYY-MM-DD-HH-MM-SS, with filenames automatically generated by the system.

RoleStringNoServiceRoleforTOSLoggingThe role name used to grant the object storage permission to read all files from the source bucket and write files to the target bucket. This role must have TOS read-write and service access permissions. You can also use the TOS default role ServiceRoleforTOSLogging.

Response headers

This request returns public response message headers. See Common parameters.

Response body elements

There is no message element in this request response.

Sample request 1

Call the PutBucketLogging API to enable log storage.

PUT /?logging HTTP/1.1 
Host: bucketname.tos-cn-beijing.volces.com 
Authorization: authorization string 
Date: Fri, 30 Jul 2021 06:45:39 GMT 
{ 
  "LoggingEnabled": { 
    "TargetBucket": "test", 
    "TargetPrefix": "prefix", 
    "Role": "ServiceRoleforTOSLogging" 
  } 
}

Sample response 1

HTTP/1.1 200 OK 
x-tos-id-2: 4fac130beeb50032-a444ed0 
x-tos-request-id: 4fac130beeb50032-a444ed0 
Date: Mon, 12 May 2025 07:02:38 GMT 
server: TosServer 
Content-Length: 0

Sample request 2

Call the PutBucketLogging interface to disable log storage

PUT /?logging HTTP/1.1 
Host: bucketname.tos-cn-beijing.volces.com 
Authorization: authorization string 
Date: Fri, 30 Jul 2021 06:45:39 GMT 
{}

Sample response 2

HTTP/1.1 200 OK 
x-tos-id-2: 4fac130beeb50032-a444ed0 
x-tos-request-id: 4fac130beeb50032-a444ed0 
Date: Mon, 12 May 2025 06:54:12 GMT 
server: TosServer 
Content-Length: 0
Last updated: 2025.06.30 17:27:07