A number of environment variables can be used to configure the behavior of the library. There are also functions to configure this behavior in code. The environment variables are convenient when troubleshooting problems.
Setting the Default Project
Some of the GCS APIs need aprojectas a parameter. For such APIs the application can (a) call an overload that takes the project id as a parameter, (b) define the project explicitly when theClientobject is constructed, or (c) set theGOOGLE_CLOUD_PROJECTenvironment variable to the desired project id. If you have set this environment variable the code can be even simpler:
GOOGLE_CLOUD_CPP_STORAGE_REST_CONFIG=...: configuration for the REST protocol, but currently unused.
GOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG=...: used withgoogle::cloud::storage_experimental::DefaultGrpcClient()to configure configure the gRPC protocol. Setting this tomediaenables gRPC for just media operations (reading and writing data), while setting this tometadataenables gRPC for all operations. Note that gRPC support is an early access program. Contact Google Cloud support for details.
CLOUD_STORAGE_ENABLE_TRACING=raw-client: enables logging for each "RPC" generated by the library. Unless you have configured your own logging backend, you should also setGOOGLE_CLOUD_CPP_ENABLE_CLOGto produce any output on the program's console.
CLOUD_STORAGE_ENABLE_TRACING=http: enables logging for the full http traffic generated by the library.
CLOUD_STORAGE_ENABLE_TRACING=raw-client,http: enables all logging.
See Also
google::cloud::GrpcTracingOptionsOptionGOOGLE_CLOUD_CPP_ENABLE_CLOG=yes: turns on logging in the library, basically the library always "logs" but the logging infrastructure has no backend to actually print anything until the application sets a backend or they set this environment variable.
[[["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."],[[["\u003cp\u003eThis document provides details on configuring the behavior of the C++ storage library using environment variables, including troubleshooting, project settings, and endpoint overrides.\u003c/p\u003e\n"],["\u003cp\u003eThe library supports setting a default project for APIs that require a project parameter through the \u003ccode\u003eGOOGLE_CLOUD_PROJECT\u003c/code\u003e environment variable.\u003c/p\u003e\n"],["\u003cp\u003eEndpoint overrides for testing are available through the \u003ccode\u003eCLOUD_STORAGE_EMULATOR_ENDPOINT\u003c/code\u003e variable, with \u003ccode\u003eCLOUD_STORAGE_TESTBENCH_ENDPOINT\u003c/code\u003e being deprecated in its favor.\u003c/p\u003e\n"],["\u003cp\u003eExperimental gRPC behaviors can be enabled using \u003ccode\u003eGOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG\u003c/code\u003e, allowing for gRPC use in either media operations or all operations.\u003c/p\u003e\n"],["\u003cp\u003eDetailed logging for RPC calls and HTTP traffic can be activated by setting \u003ccode\u003eCLOUD_STORAGE_ENABLE_TRACING\u003c/code\u003e and \u003ccode\u003eGOOGLE_CLOUD_CPP_ENABLE_CLOG\u003c/code\u003e to view the logs.\u003c/p\u003e\n"]]],[],null,["Version 2.17.0keyboard_arrow_down\n\n- [2.42.0-rc (latest)](/cpp/docs/reference/storage/latest/storage-env)\n- [2.41.0](/cpp/docs/reference/storage/2.41.0/storage-env)\n- [2.40.0](/cpp/docs/reference/storage/2.40.0/storage-env)\n- [2.39.0](/cpp/docs/reference/storage/2.39.0/storage-env)\n- [2.38.0](/cpp/docs/reference/storage/2.38.0/storage-env)\n- [2.37.0](/cpp/docs/reference/storage/2.37.0/storage-env)\n- [2.36.0](/cpp/docs/reference/storage/2.36.0/storage-env)\n- [2.35.0](/cpp/docs/reference/storage/2.35.0/storage-env)\n- [2.34.0](/cpp/docs/reference/storage/2.34.0/storage-env)\n- [2.33.0](/cpp/docs/reference/storage/2.33.0/storage-env)\n- [2.32.0](/cpp/docs/reference/storage/2.32.0/storage-env)\n- [2.31.0](/cpp/docs/reference/storage/2.31.0/storage-env)\n- [2.30.0](/cpp/docs/reference/storage/2.30.0/storage-env)\n- [2.29.0](/cpp/docs/reference/storage/2.29.0/storage-env)\n- [2.28.0](/cpp/docs/reference/storage/2.28.0/storage-env)\n- [2.27.0](/cpp/docs/reference/storage/2.27.0/storage-env)\n- [2.26.0](/cpp/docs/reference/storage/2.26.0/storage-env)\n- [2.25.1](/cpp/docs/reference/storage/2.25.1/storage-env)\n- [2.24.0](/cpp/docs/reference/storage/2.24.0/storage-env)\n- [2.23.0](/cpp/docs/reference/storage/2.23.0/storage-env)\n- [2.22.1](/cpp/docs/reference/storage/2.22.1/storage-env)\n- [2.21.0](/cpp/docs/reference/storage/2.21.0/storage-env)\n- [2.20.0](/cpp/docs/reference/storage/2.20.0/storage-env)\n- [2.19.0](/cpp/docs/reference/storage/2.19.0/storage-env)\n- [2.18.0](/cpp/docs/reference/storage/2.18.0/storage-env)\n- [2.17.0](/cpp/docs/reference/storage/2.17.0/storage-env)\n- [2.16.0](/cpp/docs/reference/storage/2.16.0/storage-env)\n- [2.15.1](/cpp/docs/reference/storage/2.15.1/storage-env)\n- [2.14.0](/cpp/docs/reference/storage/2.14.0/storage-env)\n- [2.13.0](/cpp/docs/reference/storage/2.13.0/storage-env)\n- [2.12.0](/cpp/docs/reference/storage/2.12.0/storage-env)\n- [2.11.0](/cpp/docs/reference/storage/2.11.0/storage-env) \n\nEnvironment Variables\n=====================\n\nA number of environment variables can be used to configure the behavior of the library. There are also functions to configure this behavior in code. The environment variables are convenient when troubleshooting problems.\n\nSetting the Default Project\n---------------------------\n\nSome of the GCS APIs need a [project](https://cloud.google.com/storage/docs/projects) as a parameter. For such APIs the application can (a) call an overload that takes the project id as a parameter, (b) define the project explicitly when the `Client` object is constructed, or (c) set the `GOOGLE_CLOUD_PROJECT` environment variable to the desired project id. If you have set this environment variable the code can be even simpler: \n\n namespace gcs = ::google::cloud::storage;\n using ::google::cloud::StatusOr;\n [](gcs::Client client, std::string const& bucket_name) {\n StatusOr\u003cgcs::BucketMetadata\u003e bucket_metadata =\n client.CreateBucket(bucket_name, gcs::BucketMetadata());\n if (!bucket_metadata) throw std::move(bucket_metadata).status();\n\n std::cout \u003c\u003c \"Bucket \" \u003c\u003c bucket_metadata-\u003ename() \u003c\u003c \" created.\"\n \u003c\u003c \"\\nFull Metadata: \" \u003c\u003c *bucket_metadata \u003c\u003c \"\\n\";\n }\n\n###### See Also\n\n[`google::cloud::storage::ProjectIdOption`](/cpp/docs/reference/storage/2.17.0/structgoogle_1_1cloud_1_1storage_1_1ProjectIdOption)\n\nEndpoint Overrides\n------------------\n\n`CLOUD_STORAGE_EMULATOR_ENDPOINT=...`: override the default endpoint used by the library. Intended for testing only.\n\n`CLOUD_STORAGE_TESTBENCH_ENDPOINT=...`: **DEPRECATED** please use `CLOUD_STORAGE_EMULATOR_ENDPOINT` instead.\n\n###### See Also\n\n[`google::cloud::storage::RestEndpointOption`](/cpp/docs/reference/storage/2.17.0/structgoogle_1_1cloud_1_1storage_1_1RestEndpointOption)\n\n###### See Also\n\n[`google::cloud::storage::IamEndpointOption`](/cpp/docs/reference/storage/2.17.0/structgoogle_1_1cloud_1_1storage_1_1IamEndpointOption)\n\nEnabling Experimental Behaviors\n-------------------------------\n\n`GOOGLE_CLOUD_CPP_STORAGE_REST_CONFIG=...`: configuration for the REST protocol, but currently unused.\n\n`GOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG=...`: used with [`google::cloud::storage_experimental::DefaultGrpcClient()`](/cpp/docs/reference/storage/2.17.0/namespacegoogle_1_1cloud_1_1storage__experimental) to configure configure the gRPC protocol. Setting this to `media` enables gRPC for just media operations (reading and writing data), while setting this to `metadata` enables gRPC for all operations. Note that gRPC support is an early access program. Contact Google Cloud support for details.\n\n###### See Also\n\n[`google::cloud::storage_experimental::GrpcPluginOption`](/cpp/docs/reference/storage/2.17.0/structgoogle_1_1cloud_1_1storage__experimental_1_1GrpcPluginOption)\n\nLogging\n-------\n\n`CLOUD_STORAGE_ENABLE_TRACING=raw-client`: enables logging for each \"RPC\" generated by the library. Unless you have configured your own logging backend, you should also set `GOOGLE_CLOUD_CPP_ENABLE_CLOG` to produce any output on the program's console.\n\n`CLOUD_STORAGE_ENABLE_TRACING=http`: enables logging for the full http traffic generated by the library.\n\n`CLOUD_STORAGE_ENABLE_TRACING=raw-client,http`: enables all logging.\n\n###### See Also\n\n[`google::cloud::GrpcTracingOptionsOption`](https://cloud.google.com/cpp/docs/reference/common/latest/structgoogle_1_1cloud_1_1GrpcTracingOptionsOption.html)`GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes`: turns on logging in the library, basically the library always \"logs\" but the logging infrastructure has no backend to actually print anything until the application sets a backend or they set this environment variable.\n\n###### See Also\n\n[`google::cloud::LogBackend`](https://cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1LogBackend.html)\n\n###### See Also\n\n[`google::cloud::LogSink`](https://cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1LogSink.html)"]]