When a bucket is accessed, OBS logs all the requests for the bucket. After logging is enabled for the bucket, OBS stores the logs either in the logged bucket or another bucket that belongs to the same account and region as the logged bucket. You can search and analyze these logs to trace and locate abnormal events. This section describes how to configure logging, verify the logging configuration, and disable logging for a bucket.
Configuring Logging for a Bucket
You can use OBS Console, APIs, or SDKs to configure logging for a bucket.
Using OBS Console
- In the navigation pane of OBS Console, choose Buckets.
- In the bucket list, click the desired bucket. The Objects page is displayed.
- In the navigation pane, choose Overview.
- In the Basic Configurations area, click Logging. The Logging dialog box is displayed.
- Select Enable. For details, see Figure 1.
Figure 1 Logging 
- Configure parameters.
Table 1 Parameters for configuring logging for the bucket | Parameter | Description |
| Save Logs To | Select a bucket to store the log files of the source bucket. You can use the source bucket or another bucket as the log storage bucket. If you select another bucket, it must belong to the same account and region as the source bucket. After a log storage bucket is specified, OBS grants the log delivery user group the required write and ACL read permissions for that bucket. |
| Log File Name Prefix | The prefix of each log file name. By default, OBS assigns the bucket-name-log/ prefix. This prefix represents a folder (for storing log files) in the bucket's root directory. Each log file follows this naming format: <log-file-name-prefix>YYYY-mm-DD-HH-MM-SS-<UniqueString> - <log-file-name-prefix> is the log file name prefix you specify here.
- If <log-file-name-prefix> ends with a slash (/), the log files are stored in a folder named after the prefix (without the trailing slash) in the target bucket. Each log file is named YYYY-mm-DD-HH-MM-SS-<UniqueString>. Example: 2025-06-03-07-18-11-WKK0T9O74VAWMHB7
- If <log-file-name-prefix> does not end with a slash /, the log files are stored in the root directory of the target bucket. Each log file is named <log-file-name-prefix>YYYY-mm-DD-HH-MM-SS-<UniqueString>. Example: example-bucket-a-log2025-06-03-07-18-11-WKK0T9O74VAWMHB7
- YYYY-mm-DD-HH-MM-SS indicates when the log file was generated. The fields in it represent the year, month, day, hour, and minute, respectively.
- <UniqueString> indicates a string assigned by OBS.
|
| IAM Agency | An agency is required to grant OBS the permissions needed to upload log files to the log storage bucket. - By default, the agency only needs the upload permission (obs:object:PutObject) for the log storage bucket.
- If the log storage bucket has server-side encryption enabled, the agency also requires the KMS Administrator permission for the region where the bucket is located.
You can choose an existing IAM agency from the drop-down list or click Create Agency to create one. For details about creating an agency, see Creating an Agency for Uploading Logs. |
- Click OK.
After logging is configured for a bucket, its operation logs will appear in the log storage bucket in about 15 minutes.
Verifying the Logging Configuration of a Bucket
After configuring logging for a bucket, you can use OBS Console, APIs, SDKs, or obsutil to verify the logging configuration. You can check whether OBS has generated log files and whether you have access to them.
Using OBS Console
- In the navigation pane of OBS Console, choose Buckets.
- In the bucket list of OBS Console, click the log storage bucket to go to the Objects page.
- Check for existing log files.
Check whether any log files or the folder derived from the log file name prefix appear in the object list, based on the configured prefix and log file naming rules.
Figure 2 Checking for the log folder or log files
- Verify that you can access the log files.
- In the object list or in the log folder, click the name of a log file to open its Basic Information page.
- Click
next to the link to copy the log file link. - Open this link in a browser.
Using SDKs
- Check for existing log files.
Use any of the following SDKs to list all objects in the bucket. Then, check whether any log files appear in the results based on the configured file name prefix and log file naming rules.
- Download log files.
Use any of the following SDKs to download log files.
Disabling Logging for a Bucket
Uploading and storing bucket logs incurs costs for PUT requests and storage. If you no longer need to record logs, disable logging for the bucket. After logging is disabled, OBS stops generating new logs, but any existing logs in the log storage bucket are retained.
You can use OBS Console to disable logging for a bucket.
Using OBS Console
- In the navigation pane of OBS Console, choose Buckets.
- In the bucket list, click the desired bucket. The Objects page is displayed.
- In the navigation pane, choose Overview.
- In the Basic Configurations area, click Logging. The Logging dialog box is displayed.
- Select Disable and then click OK.
Creating an Agency for Uploading Logs
- In the Logging dialog box, click Create Agency to jump to the Agencies page on the Identity and Access Management console.
- Click Create Agency. On the displayed page, configure the parameters related to the agency for uploading logs. Keep the default settings for other parameters.
Table 2 Parameters | Parameter | Description |
| Agency Name | The name of the agency to be created The agency name cannot be left blank. |
| Agency Type | Selecting Cloud service grants permissions to an account or cloud service to operate resources within the account. In this example, you need to create an agency for uploading logs, so select Cloud service here. |
| Cloud Service | Select the cloud service to which you want to grant permissions to operate resources in your account. This parameter is mandatory when you set Agency Type to Cloud service. Select Object Storage Service (OBS) for Cloud Service. |
- Click OK. In the Agency Created dialog box that is displayed, click Cancel. If the newly created agency appears in the agency list, the agency is created successfully.
- Create a custom policy that grants OBS permissions to the agency. If a suitable policy already exists, skip this step.
- In the navigation pane of the IAM console, choose Permissions > Policies/Roles.
- On the Policies/Roles page, click Create Custom Policy in the upper right corner.
- On the Create Custom Policy page, configure the parameters as described below. Keep the default settings for other parameters.
Figure 3 Configuring a custom policy
- Policy Name: Enter a name that is easy to remember.
- Select service: Select Object Storage Service (OBS).
- Actions: Select obs:object:PutObject.
- Resources: Select Specific.
object: Select Specify resource path. The resource path format is OBS:*:*:object:bucket-name/object-name.
Replace bucket-name with the name of the log storage bucket. For example, OBS:*:*:object:piccomp/* indicates all objects in the log storage bucket piccomp.
- Click OK. If the created custom policy appears in the list, it was created successfully.
- Apply the created custom policy to the agency.
- In the navigation pane of the IAM console, choose Agencies.
- Click Authorize in the Operation column of the agency created in 2.
- On the Select Policy/Role page, select the custom policy created in 4 and click Next.
- On the Select Scope page, select All resources and click OK.
- In the Information dialog box that is displayed, click OK.
- On the Finish page, click Finish.
- (Optional) If the log storage bucket has server-side encryption enabled, add the KMS Administrator permission for the bucket's region to the agency.
- In the navigation pane of the IAM console, choose Agencies.
- Click Authorize in the Operation column of the agency created in 2.
- On the Select Policy/Role page, search for and select KMS Administrator. Then, click Next.
- Select Region-specific projects for Scope, and select the projects in the region where the log storage bucket resides.
- Click OK.
Creating a Trust Agency for Uploading Logs
- In the Logging dialog box, click View Agencies to go to the Agencies page on the IAM console.
- Click Go to New Console in the upper right corner. In the navigation pane of the new IAM console, choose Agencies.
- Click Create Trust Agency.
- Enter an agency name.
- Set Agency Type to Cloud service.
- Select Object Storage Service for Cloud Service.
- Choose a maximum session duration.
- Click OK.
- Click Authorize. For details about the authorization, see Creating an Agency for Uploading Logs.
- Go back to the Agencies page on the new IAM console.
- Search for the newly created agency and click Modify in the Operation column.
- Click the Trust Policy tab and then Edit Trust Policy. The trust policy is as follows:
{
"Version": "5.0",
"Statement": [
{
"Action": [
"sts:agencies:assume",
"sts::tagSession"
],
"Effect": "Allow",
"Principal": {
"Service": [
"service.OBS"
]
}
}
]
} - Click OK to save the policy.
Are Interrupted Requests Recorded in OBS Bucket Logs?
OBS does not record interrupted requests. If you initiate a request through an API or SDK, check the returned value to identify the cause of the interruption.
Why Cannot I Find Request Records in the OBS Bucket Logs?
Possible causes include:
- CDN caching: If a CDN acceleration domain is configured and the requested data is cached at a CDN PoP, the PoP returns the data directly to the client. The request does not reach OBS, so no OBS log is generated. To view these requests, download CDN logs. For details, see Log Management.
- Client-side interruption: If the request is interrupted before reaching OBS due to client network issues or other reasons, OBS cannot record it. If you initiate a request through an API or SDK, check the returned value to identify the cause of the interruption.
- Log storage failures: Network or configuration issues may prevent logs from being written to the OBS bucket.
- Incorrect bucket queried: For example, you have configured bucket A to store logs, but you are querying request records in bucket B.