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

Obtaining the Bucket Logging Configuration

Functions

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.
  • By default, buckets in the Infrequent Access or Archive storage class cannot be used to store log files. Stored log files occupy storage space in the bucket and are billed the same way as user-stored data.

Authorization Information

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 need to grant 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 need to grant 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 need to grant the obs:bucket:GetBucketLogging permission. For details, see Creating a Custom Bucket Policy.

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

This request contains no message parameters.

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 to specify the bucket logging status. Table 1 describes the elements.

Table 1 Response body parameters

Element

Description

BucketLoggingStatus

Container for logging status information

Type: container

Agency

Name of the agency created by the owner of the logging bucket for uploading log files by OBS

Type: string

LoggingEnabled

Container for logging information. This element enables or disables the logging function. Present this element when enabling the logging. Otherwise, absent it.

Type: container

Grant

Container for the grantee and the granted permissions

Type: container

Grantee

Container for the user that is granted the logging permission

Type: container

ID

Grantee domain ID, a globally unique ID

Type: string

Permission

Logging permission granted to the grantee for a bucket. The bucket owner is automatically granted the FULL_CONTROL permission when creating the bucket. Logging permissions control access to different logs.

Type: string

Value options: FULL_CONTROL, READ, WRITE

TargetBucket

When enabling the logging function, the owner of the bucket being logged can specify a target bucket to store the generated log files. Log files generated for multiple buckets can be stored in the same target bucket. If you do so, you need to specify different TargetPrefixes to classify logs for different buckets.

Type: string

TargetPrefix

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

Type: string

TargetSorting

Type based on which logs are sorted.

Type: string

Valid values: DAY and HOUR

No

TargetGrants

Container for granting information

Type: container

Error Responses

No special error responses are returned. For details about error responses, see Table 2.

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

References