A large number of access logs are generated when you access OSS. After you enable the logging function for a bucket, OSS automatically records the access logs for the bucket on the hour, write the logs into an object that follows the specified naming convention, and store the object in the target bucket that you specify. For more information, see Access logging in the OSS developer guide.
- Log on to the OSS console.
- In the left-side bucket list, click the name of the bucket that you want to set the logging unction.
- Click the Basic Settings tab and find the Log area.
- Click Configure and then set Destination Bucket and Log Prefix.
- Destination Bucket: In the drop-down list, select the name of the bucket used to store logs. You can only select buckets owned by you and in the same region as the bucket for which the logging function is enabled.
- Log Prefix: Enter the directory where logs are stored and the prefix of the logs. For example, if you enter log/<TargetPrefix>, logs are stored in the log/ directory.
- Click Save.
Logging naming convention
The following example is used to describe the naming convention for objects that store access logs.
- <TargetPrefix>: Indicates the specified log prefix.
- <SourceBucket>: Indicates the name of the source bucket.
- YYYY-MM-DD-HH-MM-SS: Indicates the time when the log is created, in which YYYY indicates the year, MM indicates the month, DD indicates the day, HH indicates the hour, MM indicates the minute, and SS indicates the second.
- <UniqueString>: Indicates a string generated by OSS.
For example, the name of an object used to store OSS access logs is as follows:
- MyLog is the specified log prefix.
- oss-example is the name of the source bucket.
- 2015-09-10-04-00-00 indicates the time the the log is created.
- 0000 is a string generated by OSS.