All Products
Search
Document Center

Object Storage Service:GetBucketLogging

Last Updated:Jun 08, 2025

Views the access logging configuration of a bucket. Only the owner of a bucket can view the access logging configuration of the bucket.

Request syntax

GET /? logging HTTP/1.1
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue

Response elements

Name

Type

Description

BucketLoggingStatus

Container

Indicates the container used to store access logging configuration of a bucket.

Sub-node: LoggingEnabled

Parent node: None

Note

If no logging rules are set for the source bucket, OSS returns an XML message body in which the value of BucketLoggingStatus is null.

LoggingEnabled

Container

Indicates the container used to store access logging information. This element is returned if it is enabled and is not returned if it is disabled.

Sub-node: TargetBucket and TargetPrefix

Parent node: BucketLoggingStatus

TargetBucket

Character

Indicates the bucket that stores access logs.

Sub-node: None

Parent node: BucketLoggingStatus.LoggingEnabled

TargetPrefix

Character

Indicates the prefix of the names of stored access log files.

Sub-node: None

Parent node: BucketLoggingStatus.LoggingEnabled

Examples

Request example:

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 example returned when logging rules are set for the bucket:

HTTP/1.1 200
x-oss-request-id: 534B371674E88A4D8906008B
Date: Fri, 04 May 2012 05:31:04 GMT
Connection: keep-alive
Content-Length: 210  
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>
    </LoggingEnabled>
</BucketLoggingStatus>

Response example returned when no logging rules are set for the bucket:

HTTP/1.1 200 
x-oss-request-id: 534B371674E88A4D8906008B
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>

OSS SDKs

The SDKs of this API are as follows:

ossutil

For information about the ossutil command that corresponds to the GetBucketLogging operation, see get-bucket-logging.

Error codes

Error code

HTTP status code

Description

NoSuchBucket

404

The target bucket does not exist.

AccessDenied

403

You do not have the permission to view the access logging configuration of a bucket. Only the owner of a bucket can view the access logging configuration of the bucket.