To write logs to stderr instead, exclude the last line from the
previous example. For more information about other options, see
gRPC environment
variables.
Error Details
Google Cloud services follow AIP-193 guidelines
when returning errors. Google Cloud services use a defined set of standard
error payloads, which you can find in
google.rpc.error_details.proto.
These cover the most common API errors, such as quota failure and invalid
parameters.
API errors emitted by PHP client libraries contain message, code, status, and details fields.
Within the details field, additional google.rpc.ErrorInfo data appears in
reason, domain, and metadata fields.
The following sample shows an error that might appear if you called the
Translation library with a cloud project before enabling the Translate API:
Google\ApiCore\ApiException: {
"reason": "SERVICE_DISABLED",
"domain": "googleapis.com",
"errorInfoMetadata": {
"consumer": "projects\PROJECT_ID",
"service": "translate.googleapis.com"
},
"message": "Cloud Translation API has not been used in project PROJECT_ID before or it is disabled. Enable it by visiting https:\/\/console.developers.google.com\/apis\/api\/translate.googleapis.com\/overview?project=PROJECT_ID then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"code": 7,
"status": "PERMISSION_DENIED",
"details": [
{
"@type": "google.rpc.errorinfo-bin",
"reason": "SERVICE_DISABLED",
"domain": "googleapis.com",
"metadata": {
"consumer": "projects\PROJECT_ID",
"service": "translate.googleapis.com"
}
},
{
"@type": "google.rpc.help-bin",
"links": [
{
"description": "Google developers console API activation",
"url": "https:\/\/console.developers.google.com\/apis\/api\/translate.googleapis.com\/overview?project=PROJECT_ID"
}
]
}
]
}
For more information about the general error model for Google APIs, see
Cloud API Errors.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Troubleshooting\n\nTracing GRPC issues\n-------------------\n\n### Before you begin\n\nBe sure to initialize and enable write permissions before writing to your log\nfile. In the following example, the log file is named `/var/log/grpc.log`: \n\n touch /var/log/grpc.log\n chmod 666 /var/log/grpc.log\n\nIf you encounter file permissions issues, you might need to preface the\nprevious commands with `sudo`.\n\n### Logging to a file\n\nTo save gRPC logs to a file, add the following lines to your `php.ini` file: \n\n grpc.grpc_verbosity=debug\n grpc.grpc_trace=all,-timer_check\n grpc.log_filename=/var/log/grpc.log\n\nTo write logs to `stderr` instead, exclude the last line from the\nprevious example. For more information about other options, see\n[gRPC environment\nvariables](https://grpc.github.io/grpc/php/md_doc_environment_variables.html).\n| **Note:** Enabling gRPC logs can also create many logs that grow large quickly. If you enable logging, be sure to clear the log file regularly with a `cron` job, set up a log file rotation, or turn logging off when finished debugging.\n\nError Details\n-------------\n\nGoogle Cloud services follow [AIP-193](https://google.aip.dev/193) guidelines\nwhen returning errors. Google Cloud services use a defined set of standard\nerror payloads, which you can find in\n[google.rpc.error_details.proto](https://github.com/googleapis/googleapis/blob/master/google/rpc/error_details.proto).\nThese cover the most common API errors, such as quota failure and invalid\nparameters.\n\nAPI errors emitted by PHP client libraries contain `message`, `code`, `status`, and `details` fields.\nWithin the `details` field, additional `google.rpc.ErrorInfo` data appears in\n`reason`, `domain`, and `metadata` fields.\nThe following sample shows an error that might appear if you called the\nTranslation library with a cloud project before enabling the Translate API: \n\n```\nGoogle\\ApiCore\\ApiException: {\n \"reason\": \"SERVICE_DISABLED\",\n \"domain\": \"googleapis.com\",\n \"errorInfoMetadata\": {\n \"consumer\": \"projects\\PROJECT_ID\",\n \"service\": \"translate.googleapis.com\"\n },\n \"message\": \"Cloud Translation API has not been used in project PROJECT_ID before or it is disabled. Enable it by visiting https:\\/\\/console.developers.google.com\\/apis\\/api\\/translate.googleapis.com\\/overview?project=PROJECT_ID then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.\",\n \"code\": 7,\n \"status\": \"PERMISSION_DENIED\",\n \"details\": [\n {\n \"@type\": \"google.rpc.errorinfo-bin\",\n \"reason\": \"SERVICE_DISABLED\",\n \"domain\": \"googleapis.com\",\n \"metadata\": {\n \"consumer\": \"projects\\PROJECT_ID\",\n \"service\": \"translate.googleapis.com\"\n }\n },\n {\n \"@type\": \"google.rpc.help-bin\",\n \"links\": [\n {\n \"description\": \"Google developers console API activation\",\n \"url\": \"https:\\/\\/console.developers.google.com\\/apis\\/api\\/translate.googleapis.com\\/overview?project=PROJECT_ID\"\n }\n ]\n }\n ]\n}\n```\n\nFor more information about the general error model for Google APIs, see\n[Cloud API Errors](https://cloud.google.com/apis/design/errors)."]]