Help Center/ Object Storage Service/ API Reference/ Bucket APIs/ Bucket Logging/ Obtaining the Bucket Logging Configuration
Updated on 2026-07-27 GMT+08:00

Obtaining the Bucket Logging Configuration

Function

After logging is enabled for a bucket, you can call this API to query the logging configuration of the bucket.

Constraints

  • You can store logs in the logged bucket or another bucket. However, the log storage bucket and logged bucket must belong to the same account and region.

Authorization

To call this API, you must be the bucket owner or have the permission to obtain the logging configuration of a bucket. You are advised to use IAM or bucket policies for authorization. For details about OBS authorization methods, see Differences Between OBS Permissions Control Methods.

  • If you use IAM for authorization, you need to use either role/policy-based authorization or identity policy-based authorization and configure the required permissions:
    • If you use role/policy-based authorization (IAM v3 APIs in the old IAM version), you must have the obs:bucket:GetBucketLogging permission. For details, see Creating a Custom IAM Policy.
    • If you use identity policy-based authorization (IAM v5 APIs in the new IAM version), you must have the obs:bucket:getBucketLogging permission, as shown in the following table. For details, see Creating a Custom IAM Identity Policy.

      Action

      Access Level

      Resource Type (*: Required)

      Condition Key

      Alias

      Dependencies

      obs:bucket:getBucketLogging

      Read

      bucket *

      -

      -

      -

      • obs:EpochTime
      • obs:SourceIp
      • obs:TlsVersion
      • obs:CustomDomain
  • If you use bucket policies for authorization, you must have the obs:bucket:GetBucketLogging permission. For details, see Creating a Custom Bucket Policy.

URI

GET /

Calling Method

For details, see Calling APIs. Before calling this API, calculate the API signature and add it to the request.

You can debug this API in API Explorer.

Request Syntax

The following is an example request. Replace BucketName with your bucket name and RegionID with the ID of the region where your bucket resides. You can obtain the region ID by referring to Supported Regions.

1
2
3
4
GET /?logging HTTP/1.1 
Host: BucketName.obs.RegionID.myhuaweicloud.com 
Date: GMT Date
Authorization: SignatureValue

URI Parameters

Table 1 URI parameters

Parameter

Type

Mandatory

Description

logging

String

No

Definition

An identifier that marks this API as related to bucket logging.

Constraints

N/A

Range

logging

Default Value

N/A

Request Headers

This request uses common headers. For details, see Table 3.

Request Body

This request contains no request body parameters.

Response Syntax

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
HTTP/1.1 status_code
Content-Type: application/xml 
Date: date
Content-Length: length

<?xml version="1.0" encoding="UTF-8"?> 
<BucketLoggingStatus xmlns="http://obs.region.myhuaweicloud.com/doc/2015-06-30/">
<Agency>agency-name</Agency>
<LoggingEnabled> 
    <TargetBucket>bucketName</TargetBucket> 
    <TargetPrefix>prefix</TargetPrefix> 
    
        <TargetGrants> 
            <Grant> 
                <Grantee> 
                    <ID>id</ID> 
                </Grantee> 
                <Permission>permission</Permission> 
            </Grant> 
        </TargetGrants> 
    </LoggingEnabled> 
</BucketLoggingStatus>

Response Headers

This response uses common headers. For details, see Table 1.

Response Body

This response contains elements that specify the bucket logging status. Table 2 describes the elements.

Table 2 Response body parameters

Parameter

Type

Description

BucketLoggingStatus

Container

Definition

Container for logging status information.

Range

N/A

Agency

String

Definition

Name of the IAM agency created by the owner of the target bucket on IAM. The agency must have the obs:bucket:PutBucketLogging permission.

Range

N/A

LoggingEnabled

Container

Definition

Container for logging information. Include this element when logging needs to be enabled. Otherwise, omit it. You can add specific logging information in this element.

Range

N/A

Grant

Container

Definition

Container for the grantee and the granted permissions. It describes who has the permission to access the generated log files.

Range

N/A

Grantee

Container

Definition

Container for the user that is granted the logging permission.

Range

N/A

ID

String

Definition

Account ID of the authorized user, which is globally unique.

Range

N/A

Permission

String

Definition

Permissions of the grantee to the generated logs.

Range

  • READ: grants the permission to obtain the bucket objects and bucket metadata.
  • WRITE: grants the permission to upload objects to the bucket. It allows authorized users to delete and overwrite existing objects in the bucket.
  • FULL_CONTROL: grants the permission to fully read, write, and delete objects in the bucket.

TargetBucket

String

Definition

Name of the bucket where logs are stored. When enabling the logging function, the owner of the bucket being logged can specify a target bucket to store the generated log files.

NOTE:
  • Ensure that the bucket owner who configures the logging function has the FULL_CONTROL permission for the bucket that stores log files.
  • If you want to store logs generated by multiple buckets in the same target bucket, you need to specify different TargetPrefix values to identify logs from different source buckets.

Range

N/A

TargetPrefix

String

Definition

You can specify a prefix using this element so that log files are named with this prefix.

Range

It can contain a maximum of 254 bytes.

TargetGrants

Container

Definition

Container for the authorization information.

Range

N/A

Error Responses

No special errors. You can find all errors in Error Code Overview.

Sample Request

1
2
3
4
5
6
GET /?logging HTTP/1.1
User-Agent: curl/7.29.0
Host: examplebucket.obs.region.myhuaweicloud.com
Accept: */*
Date: Wed, 01 Jul 2015 02:42:46 GMT
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:hUk+jTnR07hcKwJh4ousF2E1U3E=

Sample Response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
HTTP/1.1 200 OK
Server: OBS
x-obs-request-id: BF260000016436B8EEE7FBA2AA3335E3
x-obs-id-2: 32AAAQAAEAABAAAQAAEAABAAAQAAEAABCShuQJoWFpS77C8bOv1mqURv0UY+0ejx
Content-Type: application/xml
Date: Wed, 01 Jul 2015 02:42:46 GMT
Content-Length: 429

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<BucketLoggingStatus xmlns="http://obs.ap-southeast-1.myhuaweicloud.com/doc/2015-06-30/">
  <Agency>agency-name</Agency>
  <LoggingEnabled>
    <TargetBucket>log-bucket</TargetBucket>
    <TargetPrefix>mybucket-access_log-/</TargetPrefix>
    
    <TargetGrants>
      <Grant>
        <Grantee>
          <ID>b4bf1b36d9ca43d984fbcb9491b6fce9</ID>
        </Grantee>
        <Permission>READ</Permission>
      </Grant>
    </TargetGrants>
  </LoggingEnabled>
</BucketLoggingStatus>

Using SDKs to Call APIs

You are advised to use OBS SDKs to call APIs. SDKs encapsulate APIs to simplify development. You can call SDK API functions to access OBS without manually calculating signatures.

Java

Python

C

Go

BrowserJS

.NET

Android

iOS

PHP

Node.js

Harmony: not supported

Helpful Links