This directory contains samples for calling Stackdriver Logging from PHP.
Execute the snippets in the src/ directory by running
php src/SNIPPET_NAME.php
. The usage will print for each if no arguments
are provided:
$ php src/list_entries.php
Usage: php src/list_entries.php PROJECT_ID LOGGER_NAME
$ php src/list_entries.php your-project-id 'your-logger-name'
[list of entries...]
To use logging sinks, you will also need a Google Cloud Storage Bucket.
gsutil mb gs://[YOUR_PROJECT_ID]
You must add Cloud Logging as an owner to the bucket. To do so, add
[email protected]
as an owner to the bucket. See the
exporting logs
docs for complete details.
Use the Cloud SDK to provide authentication:
gcloud beta auth application-default login