6
votes

I'm using Google Cloud Storage to serve my static website to the public and wondering is there a way to enable Apache/NGINX like access logs for the bucket via the GCP web interface?

1

1 Answers

10
votes

GCS does offer access logs, although they arrive as CSV files with a bunch of information and not as Apache logs.

Enabling them is fairly simple. Say you want access logs for bucket "mybucket".

First, create another bucket to hold the access logs. Let's call it "mylogsbucket".

Second, give GCS permission to write logs to that bucket with this gsutil command:

gsutil acl ch -g [email protected]:W gs://mylogsbucket

Third, activate logging:

gsutil logging set on -b gs://mylogsbucket gs://mybucket

Usage logs for mybucket will now show up about once per hour in mylogsbucket, and storage logs recording how much data is being stored will show up once per day.

More documentation on this feature is here: https://cloud.google.com/storage/docs/access-logs