tencent cloud

masukan

Log Management

Terakhir diperbarui:2024-02-02 14:36:36

    Overview

    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.

    Sample code

    try
    {
    // Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.
    string bucket = "examplebucket-1250000000";
    PutBucketLoggingRequest request = new PutBucketLoggingRequest(bucket);
    // Set the destination path for storing logs
    request.SetTarget("targetbucket-1250000000", "logs/");
    // Execute the request
    PutBucketLoggingResult result = cosXml.PutBucketLogging(request);
    // Request succeeded
    Console.WriteLine(result.GetResultInfo());
    }
    catch (COSXML.CosException.CosClientException clientEx)
    {
    // Request failed
    Console.WriteLine("CosClientException: " + clientEx);
    }
    catch (COSXML.CosException.CosServerException serverEx)
    {
    // Request failed
    Console.WriteLine("CosServerException: " + serverEx.GetInfo());
    }
    Note:
    For more samples, please visit GitHub.

    Querying Logging Configuration

    Description

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

    Sample code

    try
    {
    // Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.
    string bucket = "examplebucket-1250000000";
    GetBucketLoggingRequest request = new GetBucketLoggingRequest(bucket);
    // Execute the request
    GetBucketLoggingResult getResult = cosXml.GetBucketLogging(request);
    // Request succeeded
    BucketLoggingStatus status = getResult.bucketLoggingStatus;
    if (status != null && status.loggingEnabled != null) {
    string targetBucket = status.loggingEnabled.targetBucket;
    string targetPrefix = status.loggingEnabled.targetPrefix;
    }
    }
    catch (COSXML.CosException.CosClientException clientEx)
    {
    // Request failed
    Console.WriteLine("CosClientException: " + clientEx);
    }
    catch (COSXML.CosException.CosServerException serverEx)
    {
    // Request failed
    Console.WriteLine("CosServerException: " + serverEx.GetInfo());
    }
    Note:
    For more samples, please visit GitHub.
    Hubungi Kami

    Hubungi tim penjualan atau penasihat bisnis kami untuk membantu bisnis Anda.

    Dukungan Teknis

    Buka tiket jika Anda mencari bantuan lebih lanjut. Tiket kami tersedia 7x24.

    Dukungan Telepon 7x24