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=...: this is deprecated.
Logging
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\u003eThe latest version available is 2.37.0-rc, with numerous older versions from 2.36.0 down to 2.11.0 also available for reference.\u003c/p\u003e\n"],["\u003cp\u003eEnvironment variables can be used to configure the library's behavior, providing a convenient way to troubleshoot issues, and can also set the default project via \u003ccode\u003eGOOGLE_CLOUD_PROJECT\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can override the default endpoint used by the library for testing purposes by setting the \u003ccode\u003eCLOUD_STORAGE_EMULATOR_ENDPOINT\u003c/code\u003e variable.\u003c/p\u003e\n"],["\u003cp\u003eThe library's logging can be enabled with options for raw-client and/or http traffic logging via the \u003ccode\u003eCLOUD_STORAGE_ENABLE_TRACING\u003c/code\u003e environment variable, which will only output if \u003ccode\u003eGOOGLE_CLOUD_CPP_ENABLE_CLOG=yes\u003c/code\u003e is also set.\u003c/p\u003e\n"]]],[],null,["Version latestkeyboard_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/latest/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/latest/structgoogle_1_1cloud_1_1storage_1_1RestEndpointOption)\n\n###### See Also\n\n[`google::cloud::storage::IamEndpointOption`](/cpp/docs/reference/storage/latest/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=...`: this is deprecated.\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)"]]