Inventory

Last updated: 2020-03-20 09:32:04

PDF

Note

This document provides an overview of API on log management and sample SDK code.

API Operation name pedagogical operation
PUT Bucket logging Set up log management Enable logging for source Bucket
GET Bucket logging Query log management Query the log configuration information of the source Bucket

Set up log management

Function description

PUT Bucket logging is used to enable logging for the source Bucket and save the Access log of the source Bucket to the specified destination bucket.

Method prototype

public void setBucketLoggingConfiguration(SetBucketLoggingConfigurationRequest setBucketLoggingConfigurationRequest);

Request Sample

String bucketName = "examplebucket-1250000000";
BucketLoggingConfiguration bucketLoggingConfiguration = new BucketLoggingConfiguration();
bucketLoggingConfiguration.setDestinationBucketName(bucketName);
bucketLoggingConfiguration.setLogFilePrefix("logs");
SetBucketLoggingConfigurationRequest setBucketLoggingConfigurationRequest = new SetBucketLoggingConfigurationRequest(bucketName, bucketLoggingConfiguration);
cosclient.setBucketLoggingConfiguration(setBucketLoggingConfigurationRequest);

Parameter description

Parameter name Description Type
SetBucketLoggingConfigurationRequest Enable log function request SetBucketLoggingConfigurationRequest

Request member description:

Request member Setting method Description Type
BucketName Constructor or set method The name of the source Bucket whose log function is enabled. The name format is BucketName-APPID. For more information, please see Naming convention String
LoggingConfiguration Constructor or set method Bucket's log function configuration BucketLoggingConfiguration

BucketLoggingConfiguration member description:

Parameter name Description Type
DestinationBucketName The name of destination bucket in which the log is stored, and the format is BucketName-APPID. For more information, please see Naming convention String
LogFilePrefix The log is stored in the designated path of destination bucket. String

Return result description

  • Success: no return value.
  • Failure: if an error occurs (such as Identity verification failure), an exception CosClientException or CosServiceException is thrown. For more information, please see Exception Handling .

Query log management

Function description

GET Bucket logging is used to query the log configuration information of the specified Bucket.

Method prototype

public BucketLoggingConfiguration getBucketLoggingConfiguration(String bucketName);

Request Sample

String bucketName = "examplebucket-1250000000";
BucketLoggingConfiguration bucketLoggingConfiguration = cosclient.getBucketLoggingConfiguration(bucketName);

Parameter description

Parameter name Description Type
BucketName Destination bucket who stores the log in BucketName-APPID format. For more information, please see Naming convention String

Return result description

  • Success: the returned BucketLoggingConfiguration, contains the name of destination bucket where the log is stored and the specified path where the log is stored in destination bucket.
  • Failure: if an error occurs (such as Identity verification failure), an exception CosClientException or CosServiceException is thrown. For more information, please see Exception Handling .