The GetBucketLogging operation queries the access log configuration of a bucket. Only the bucket owner can call this operation.
Usage notes
The GetBucketLogging operation requires the oss:GetBucketLogging permission. Grant custom access policies to RAM users.
Request syntax
GET /?logging HTTP/1.1
Host: Host
Date: GMT Date
Authorization: SignatureValue
Request headers
DescribeRegions uses only common request headers. For more information, see Common request headers.
Response headers
The response contains only common response headers. For more information, see Common response headers.
Response elements
|
Name |
Type |
Example |
Description |
|
BucketLoggingStatus |
Container |
Not applicable |
Container for the access log status. Child element: LoggingEnabled Parent element: None Note
If no logging rule is configured for the bucket, OSS returns an XML body with an empty BucketLoggingStatus element. |
|
LoggingEnabled |
Container |
Not applicable |
Container for access log information. Returned only when logging is enabled. Child elements: TargetBucket, TargetPrefix, and LoggingRole Parent element: BucketLoggingStatus |
|
TargetBucket |
String |
mybucketlogs |
The bucket that stores access logs. Child element: None Parent element: BucketLoggingStatus.LoggingEnabled |
|
TargetPrefix |
String |
mybucket-access_log/ |
The prefix of stored access log files. Child element: None Parent element: BucketLoggingStatus.LoggingEnabled |
|
LoggingRole |
String |
AliyunOSSLoggingDefaultRole |
The role for log storage authorization. Child element: None Parent element: BucketLoggingStatus.LoggingEnabled |
Examples
General-purpose bucket
Request
Get /?logging HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Thu, 17 Apr 2025 05:31:04 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e
Response
-
Response when logging is enabled
HTTP/1.1 200 x-oss-request-id: 534B371674E88A4D8906**** Date: Fri, 04 May 2012 05:31:04 GMT Connection: keep-alive Content-Length: 280 Server: AliyunOSS <?xml version="1.0" encoding="UTF-8"?> <BucketLoggingStatus xmlns="http://doc.oss-cn-hangzhou.aliyuncs.com"> <LoggingEnabled> <TargetBucket>mybucketlogs</TargetBucket> <TargetPrefix>mybucket-access_log/</TargetPrefix> <LoggingRole>AliyunOSSLoggingDefaultRole</LoggingRole> </LoggingEnabled> </BucketLoggingStatus> -
Response when logging is disabled
HTTP/1.1 200 x-oss-request-id: 534B371674E88A4D8906**** Date: Fri, 04 May 2012 05:31:04 GMT Connection: keep-alive Content-Length: 110 Server: AliyunOSS <?xml version="1.0" encoding="UTF-8"?> <BucketLoggingStatus xmlns="http://doc.oss-cn-hangzhou.aliyuncs.com"> </BucketLoggingStatus>
Vector bucket
Vector buckets use standard Alibaba Cloud region IDs (such as cn-hangzhou) in the Host header, not legacy OSS region IDs (such as oss-cn-hangzhou).
Request
Get /?logging HTTP/1.1
Host: exampebucket-123***456.cn-hangzhou-internal.oss-vectors.aliyuncs.com
Date: Thu, 17 Apr 2025 05:31:04 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e
Response
HTTP/1.1 200
x-oss-request-id: 534B371674E88A4D8906****
Date: Fri, 04 May 2012 05:31:04 GMT
Connection: keep-alive
Content-Length: 280
Server: AliyunOSS
{
"BucketLoggingStatus": {
"LoggingEnabled": {
"TargetBucket": "mybucketlogs",
"TargetPrefix": "mybucket-access_log/",
"LoggingRole": "AliyunOSSLoggingDefaultRole"
}
}
}
SDK
Supported SDKs:
ossutil command-line tool
The corresponding ossutil command is get-bucket-logging.
Error codes
|
Error code |
HTTP status code |
Description |
|
NoSuchBucket |
404 |
The specified bucket does not exist. |
|
AccessDenied |
403 |
You do not have permission to view the bucket's access log configuration. Only the bucket owner has this permission. |