The following steps describe how to set up logs delivery for a specific bucket using the JSON API.
-
Create a bucket to store your logs.
Create a bucket to store your logs using the following request:
POST /storage/v1/b?project=project-id
Host: storage.googleapis.com
{
"name": "example-logs-bucket"
}
-
Set permissions to allow Cloud Storage WRITE permission to the bucket. To grant Cloud Storage WRITE access to your bucket, add an ACL entry for the bucket that grants the cloud-storage-analytics@google.com group write access. You can do this with the following request to the BucketAccessControls resource for the logging bucket:
POST /storage/v1/b/example-logs-bucket/acl
Host: storage.googleapis.com
{
"entity": "group-cloud-storage-analytics@google.com",
"role": "WRITER"
}
-
Enable logging for your bucket. You can enable logging for your bucket using the following request:
PATCH /storage/v1/b/example-bucket
Host: storage.googleapis.com
{
"logging": {
"logBucket": "example-logs-bucket",
"logObjectPrefix": "log_object_prefix"
}
}