• Object Storage Service

  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Python SDK)
  4. Access Logging
  5. Viewing Bucket Logging

Viewing Bucket Logging

You can call ObsClient.getBucketLoggingConfiguration to view the logging settings of a bucket. Sample code is as follows:

# Import the module.
from com.obs.client.obs_client import ObsClient
# Create an instance of ObsClient.
obsClient = ObsClient(
    access_key_id='*** Provide your Access Key ***',    
    secret_access_key='*** Provide your Secret Key ***',    
resp = obsClient.getBucketLoggingConfiguration('bucketname')

if resp.status < 300:
    print('requestId:', resp.requestId)
    print('targetBucket:', resp.body.targetBucket)
    print('targetPrefix:', resp.body.targetPrefix)
    index = 1    
    for grant in resp.body.targetGrants:
        print('grant [' + str(index) + ']')
        print('grant_id:', grant.grantee.grantee_id)        
        print('grant_name:', grant.grantee.grantee_name)        
        print('group:', grant.grantee.group)       
        print('permission:', grant.permission)
        index += 1
    print('errorCode:', resp.errorCode)
    print('errorMessage:', resp.errorMessage)