PutTableBucketLogging
Sets the access logging configuration for a specified table bucket.
Usage notes
-
The destination bucket that receives logs must already exist and must belong to the same account and the same region as the table bucket. The destination bucket cannot be an HNS bucket or the table bucket itself.
-
When logging is enabled, the caller must also pass the oss:PutObject permission check on the destination bucket. The block public access configuration of the destination bucket is also validated.
-
OSS Tables requests that carry a request body must send Content-MD5. The value is the Base64-encoded MD5 digest of the actual request body. The server checks this header based on the signature type and the configuration.
-
To disable logging, you can set BucketLoggingStatus to an empty object {}, or call the DeleteTableBucketLogging operation.
Permissions
|
API |
Action |
Description |
|
PutTableBucketLogging |
oss:PutTableBucketLogging |
Sets the access logging configuration of the table bucket. |
Request syntax
PUT /buckets/{tableBucketARN}/logging HTTP/1.1
Content-Type: application/json
Host: cn-hangzhou.oss-tables.aliyuncs.com
Date: GMT Date
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/osstables/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c****
Content-MD5: {Base64(MD5(request-body))}
{
"BucketLoggingStatus": {
"LoggingEnabled": {
"TargetBucket": "my-log-bucket",
"TargetPrefix": "tablelog/",
"LoggingRole": "AliyunOSSLoggingDefaultRole",
"TargetSuffix": {
"UseRandomPart": false
}
}
}
}
Request parameters
|
Parameter |
Type |
Required |
Example |
Description |
|
tableBucketARN |
string |
Yes |
acs:osstables:cn-hangzhou:1234567890:bucket/my-table-bucket |
The ARN of the table bucket. Format: acs:osstables:{region}:{uid}:bucket/{bucketName}. This parameter is part of the URI, and must be URL-encoded when placed in the path. |
|
BucketLoggingStatus |
container |
Yes |
- |
The logging configuration object. This parameter is part of the request body. If LoggingEnabled is not included in the object, logging is disabled. Parent node: None Child nodes: LoggingEnabled |
|
LoggingEnabled |
container |
No |
- |
The logging configuration used when logging is enabled. This parameter is required to enable logging. An empty object {} cannot be used to disable logging. Parent node: BucketLoggingStatus Child nodes: TargetBucket, TargetPrefix, TargetSuffix, PushSuccessMarker, LoggingRole, ObjectKeyFormat |
|
TargetBucket |
string |
Yes |
my-log-bucket |
The name of the destination bucket that receives logs. It must be a regular OSS bucket. It cannot be an HNS bucket or the table bucket itself. This parameter is required when logging is enabled. Parent node: LoggingEnabled Child nodes: None |
|
TargetPrefix |
string |
No |
tablelog/ |
The prefix of log object names. Default value: empty. The prefix cannot start with a forward slash (/) or a backslash (\). Parent node: LoggingEnabled Child nodes: None |
|
TargetSuffix |
container |
No |
- |
The suffix configuration of log object names. Parent node: LoggingEnabled Child nodes: UseRandomPart |
|
UseRandomPart |
boolean |
No |
false |
Specifies whether to use a random suffix in log object names. Default value: false. We recommend that you pass this parameter explicitly as shown in the example. Parent node: TargetSuffix Child nodes: None |
|
PushSuccessMarker |
boolean |
No |
false |
Specifies whether to push a success marker. Default value: false. Parent node: LoggingEnabled Child nodes: None |
|
LoggingRole |
string |
No |
"" |
The role for log delivery. If this parameter is not empty, it must be a valid role identifier. Parent node: LoggingEnabled Child nodes: None |
|
ObjectKeyFormat |
string |
No |
Flat |
The naming format of log objects. Valid values: Flat, DateBucket, and BucketDate. Default value: Flat. Parent node: LoggingEnabled Child nodes: None |
Examples
The following example enables access logging for the specified table bucket. Logs are delivered to the tablelog/ prefix of my-log-bucket.
Request example
PUT /buckets/acs%3Aosstables%3Acn-hangzhou%3A1234567890%3Abucket%2Fmy-table-bucket/logging HTTP/1.1
Content-Type: application/json
Host: cn-hangzhou.oss-tables.aliyuncs.com
Date: Thu, 10 Apr 2025 08:00:00 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/osstables/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c****
Content-MD5: eB5eJF1ptWaXm4bijSPyxw==
{
"BucketLoggingStatus": {
"LoggingEnabled": {
"TargetBucket": "my-log-bucket",
"TargetPrefix": "tablelog/",
"LoggingRole": "AliyunOSSLoggingDefaultRole",
"TargetSuffix": {
"UseRandomPart": false
}
}
}
}
Response example
HTTP/1.1 200 OK
Server: AliyunOSS
x-oss-request-id: 5C06A3B67B8B5A3DA422****
x-oss-server-time: 3
Error codes
|
Error code |
HTTP status code |
Description |
|
BadRequestException |
400 |
The request body format or parameters are invalid. |
|
ForbiddenException |
403 |
The required permissions are missing or the request is not allowed. |
|
NotFoundException |
404 |
The specified table bucket does not exist. |
|
InvalidTargetBucketForLogging |
400 |
The log destination bucket is invalid, does not exist, does not belong to the same account, or is not in the same region. |