Obtaining a Bucket Logging Configuration
Functions
This operation queries the logging status of a bucket. It uses the logging sub-resource to return the logging status of a bucket.
Only the bucket owner or users granted the GetBucketLogging permission can query the bucket logging status.
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)
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
1 2 3 4 |
GET /?logging HTTP/1.1 Host: bucketname.obs.region.myhuaweicloud.com Date: date Authorization: authorization |
Request Parameters
This request contains no message parameters.
Request Headers
This request uses common headers. For details, see Table 3.
Request Elements
This request involves no elements.
Response Syntax
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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
The response to the request uses common headers. For details, see Table 1.
Response Elements
This response contains elements to specify the bucket logging status. Table 1 describes the elements.
|
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 with 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 |
|
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 |
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> |
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