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)
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
| 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.
| 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
|
| 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:
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.
Helpful Links
- To use obsutil to obtain the logging configuration of a bucket, see Log Files.
- For more information about bucket logging, see Configuring Logging for a Bucket.
- For details about the billing items involved in API operations, see Billing Items.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot