tencent cloud

All product documents
Cloud Object Storage
Log Management
Last updated: 2024-02-04 14:25:57
Log Management
Last updated: 2024-02-04 14:25:57
This document provides an overview of APIs and SDK code samples related to logging.
API
Operation
Description
Setting logging
Enables logging for a source bucket
Querying logging configuration
Queries the logging configuration of a source bucket

Setting Logging Configuration

Description

This API is used to enable logging for a source bucket and store the access logs in a specified destination bucket.

Method prototype

public Guzzle\Service\Resource\Model PutBucketLogging(array $args = array());

Sample request

<?php

require dirname(__FILE__) . '/../vendor/autoload.php';

$secretId = "SECRETID"; //Replace it with the actual SecretId, which can be viewed and managed at https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //Replace it with the actual SecretKey, which can be viewed and managed at https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //Replace it with the actual region, which can be viewed in the console at https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'schema' => 'https', // Protocol header, which is http by default
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)));

try {
$result = $cosClient->putBucketLogging(array(
'Bucket' => 'examplebucket-1250000000', // Bucket name in the format of `BucketName-APPID`, which can be viewed in the COS console at https://console.cloud.tencent.com/cos5/bucket
'LoggingEnabled' => array(
'TargetBucket' => 'examplebucket2-1250000000',
'TargetPrefix' => '',
));
// Request succeeded
print_r($result);
} catch (\Exception $e) {
// Request failed
echo($e);
}

Parameter description

Parameter
Description
Type
Bucket
Source bucket for which logging is to be enabled, in the format of BucketName-APPID. For more information, please see Bucket Naming Conventions.
String
TargetBucket
Destination bucket to store logs, in the format of BucketName-APPID. For more information, please see Bucket Naming Conventions.
String
TargetPrefix
Path to the directory that stores logs in the destination bucket
String

Querying Logging Configuration

Description

This API is used to query the logging configuration of a specified bucket.

Method prototype

public Guzzle\Service\Resource\Model GetBucketLogging(array $args = array());

Sample request

<?php

require dirname(__FILE__) . '/../vendor/autoload.php';

$secretId = "SECRETID"; //Replace it with the actual SecretId, which can be viewed and managed at https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //Replace it with the actual SecretKey, which can be viewed and managed at https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //Replace it with the actual region, which can be viewed in the console at https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'schema' => 'https', // Protocol header, which is http by default
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)));

try {
$result = $cosClient->getBucketLogging(array(
'Bucket' => 'examplebucket-1250000000', // Bucket name in the format of `BucketName-APPID`, which can be viewed in the COS console at https://console.cloud.tencent.com/cos5/bucket
));
// Request succeeded
print_r($result);
} catch (\Exception $e) {
// Request failed
echo($e);
}

Parameter description

Parameter
Description
Type
Bucket
Source bucket in the format of BucketName-APPID. For more information, please see Bucket Naming Conventions.
String

Sample response

GuzzleHttp\Command\Result Object
(
[LoggingEnabled] => Array
(
[TargetBucket] => examplebucket2-1250000000
[TargetPrefix] =>
)

[RequestId] => NWRmMWJjOThfMjZiMjU4NjRfODY4X2ExMjcy****
)

Response description

Member Variable
Description
Type
TargetBucket
Destination bucket that stores logs
String
TargetPrefix
Path to the directory that stores logs in the destination bucket
String
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon