Log storage (Python SDK V2)
Accessing OSS generates numerous access logs. You can use the log storage feature to save these logs as log files in a specified bucket. The log files are generated hourly based on a fixed naming convention.
Precautions
-
The sample code in this topic uses the China (Hangzhou) region ID
cn-hangzhouas an example. By default, a public endpoint is used. If you want to access OSS from other Alibaba Cloud services in the same region, you must use an internal endpoint. For more information about the mappings between OSS regions and endpoints, see OSS regions and endpoints. -
To enable log storage, you must have the
oss:PutBucketLoggingpermission. To view the log storage configuration, you must have theoss:GetBucketLoggingpermission. To disable log storage, you must have theoss:DeleteBucketLoggingpermission. For more information, see Grant custom permissions to a RAM user.
Method definitions
Enable log storage
put_bucket_logging(request: PutBucketLoggingRequest, **kwargs) → PutBucketLoggingResult
View the log storage configuration
get_bucket_logging(request: GetBucketLoggingRequest, **kwargs) → GetBucketLoggingResult
Disable log storage
delete_bucket_logging(request: DeleteBucketLoggingRequest, **kwargs) → DeleteBucketLoggingResult
Request parameters
|
Parameter |
Type |
Description |
|
request |
PutBucketLoggingRequest |
The request parameters. For more information, see PutBucketLoggingRequest |
|
GetBucketLoggingRequest |
The request parameters. For more information, see GetBucketLoggingRequest |
|
|
DeleteBucketLoggingRequest |
The request parameters. For more information, see DeleteBucketLoggingRequest |
Return values
|
Type |
Description |
|
PutBucketLoggingResult |
The return value. For more information, see PutBucketLoggingResult |
|
GetBucketLoggingResult |
The return value. For more information, see GetBucketLoggingResult |
|
DeleteBucketLoggingResult |
The return value. For more information, see DeleteBucketLoggingResult |
For the complete definition of enabling log storage, see put_bucket_logging.
For the complete definition of viewing the log storage configuration, see get_bucket_logging.
For the complete definition of disabling log storage, see delete_bucket_logging.