GET Bucket logging
API Description
You can use this API to obtain the access logging settings of a bucket.
Method Definition
1. ObsClient->getBucketLogging(array $parameter) 2. ObsClient->getBucketLoggingAsync(array $parameter, callable $callback)
Request Parameter
| Field | Type | Optional or Mandatory | Description |
|---|---|---|---|
| Bucket | string | Mandatory | Bucket name |
Returned Result
| Field | Type | Description | |||
|---|---|---|---|---|---|
| HttpStatusCode | integer | HTTP status code | |||
| Reason | string | Reason description | |||
| RequestId | string | Request ID returned by the OBS server | |||
| Agency | string | Agency name | |||
| LoggingEnabled | associative array | Log configuration information | |||
| TargetBucket | string | Target bucket for which logs are generated | |||
| TargetPrefix | string | Name prefix of a to-be-logged object in the target bucket | |||
| TargetGrants | indexed array | List of grantees' permission information | |||
| Grantee | associative array | Grantee | |||
| ID | string | ID of the domain to which the grantee belongs. This field is null when Type of Grantee is Group. | |||
| URI | string | Grantee group. This field is null when Type of Grantee is CanonicalUser. | |||
| Permission | string | Granted permission | |||
Sample Code
try{
$resp = $obsClient -> getBucketLogging([
'Bucket' => 'bucketname'
]);
printf("RequestId:%s\n", $resp['RequestId']);
printf("LoggingEnabled[TargetBucket]:%s\n", $resp['LoggingEnabled']['TargetBucket']);
printf("LoggingEnabled[TargetPrefix]:%s\n", $resp['LoggingEnabled']['TargetPrefix']);
printf("TargetGrants\n");
foreach ($resp['LoggingEnabled']['TargetGrants'] as $index => $grant){
printf("Grants[%d]", $index + 1);
printf("Grantee[ID]:%s\n", $grant['Grantee']['ID']);
printf("Grantee[DisplayName]:%s\n", $grant['Grantee']['DisplayName']);
printf("Grantee[URI]:%s\n", $grant['Grantee']['URI']);
printf("Permission:%s\n", $grant['Permission']);
}
}catch (Obs\Common\ObsException $obsException){
printf("ExceptionCode:%s\n", $obsException->getExceptionCode());
printf("ExceptionMessage:%s\n", $obsException->getExceptionMessage());
} Last Article: PUT Bucket logging
Next Article: PUT Bucket policy
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.