更新时间:2023-11-08 GMT+08:00
查看桶日志配置
开发过程中,您有任何问题可以在github上提交issue,或者在华为云对象存储服务论坛中发帖求助。接口参考文档详细介绍了每个接口的参数和使用方法。
您可以通过ObsClient->getBucketLogging查看桶日志配置。以下代码展示了如何查看桶日志配置:
// 引入依赖库 require 'vendor/autoload.php'; // 使用源码安装时引入SDK代码库 // require 'obs-autoloader.php'; // 声明命名空间 use Obs\ObsClient; // 创建ObsClient实例 $obsClient = new ObsClient ( [ //推荐通过环境变量获取AKSK,这里也可以使用其他外部引入方式传入,如果使用硬编码可能会存在泄露风险。 //您可以登录访问管理控制台获取访问密钥AK/SK,获取方式请参见https://support.huaweicloud.com/usermanual-ca/ca_01_0003.html 'key' => getenv('ACCESS_KEY_ID'), 'secret' => getenv('SECRET_ACCESS_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'] ); } }
父主题: 设置访问日志