文档首页 > > SDK参考> PHP> 设置访问日志> 查看桶日志配置

查看桶日志配置

分享
更新时间: 2019/04/22 GMT+08:00

您可以通过ObsClient->getBucketLogging查看桶日志配置。以下代码展示了如何查看桶日志配置:

// 引入依赖库
require 'vendor/autoload.php';
// 使用源码安装时引入SDK代码库
// require 'obs-autoloader.php';
// 声明命名空间
use Obs\ObsClient;
// 创建ObsClient实例
$obsClient = new ObsClient ( [ 
       'key' => '*** Provide your Access Key ***',
       'secret' => '*** Provide your Secret Key ***',
       'endpoint' => 'https://your-endpoint'
] );

$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'] );
if (is_array ( $resp ['LoggingEnabled'] ['TargetGrants'] )) {
       foreach ( $resp ['LoggingEnabled'] ['TargetGrants'] as $index => $grant ) {
              printf ( "TargetGrants[%d]", $index + 1 );
              printf ( "Grantee[ID]:%s\n", $grant ['Grantee'] ['ID'] );
              printf ( "Grantee[URI]:%s\n", $grant ['Grantee'] ['URI'] );
              printf ( "Permission:%s\n", $grant ['Permission'] );
       }
}
分享:

    相关文档

    相关产品

文档是否有解决您的问题?

提交成功!

非常感谢您的反馈,我们会继续努力做到更好!

反馈提交失败,请稍后再试!

*必选

请至少选择或填写一项反馈信息

字符长度不能超过200

提交反馈 取消

如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨

跳转到云社区