• Object Storage Service

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

Viewing Bucket Logging Settings

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

// Import the OBS library.
var ObsClient = require('./lib/obs');

// Create an instance of ObsClient.
var obsClient = new ObsClient({
    access_key_id: '*** Provide your Access Key ***',       
    secret_access_key: '*** Provide your Secret Key ***',       
    server : 'yourdomainname'
});

obsClient.getBucketLoggingConfiguration({
       Bucket:'bucketname'
}, (err, result) => {
       if(err){
              console.log('Error-->' + err);
       }else{
              console.log('Status-->' + result.CommonMsg.Status);
              if(result.CommonMsg.Status < 300 && result.InterfaceResult){
                     if(result.InterfaceResult.LoggingEnabled){
                           console.log('TargetBucket-->' + result.InterfaceResult.LoggingEnabled.TargetBucket);
                           console.log('TargetPrefix-->' + result.InterfaceResult.LoggingEnabled.TargetPrefix);
                     }
                     for(let i=0;i<result.InterfaceResult.LoggingEnabled.TargetGrants.Grant.length;i++){
                           console.log('Grant[' + i + ']:');
                           console.log('Grantee[ID]-->' + result.InterfaceResult.LoggingEnabled.TargetGrants.Grant[i]['Grantee']['ID']);
                           console.log('Grantee[Name]-->' + result.InterfaceResult.LoggingEnabled.TargetGrants.Grant[i]['Grantee']['Name']);
                           console.log('Grantee[URI]-->' + result.InterfaceResult.LoggingEnabled.TargetGrants.Grant[i]['Grantee']['URI']);
                           console.log('Permission-->' + result.InterfaceResult.LoggingEnabled.TargetGrants.Grant[i]['Permission']);
                     }
              }
       }
});