{"record":{"id":"57818c140066ef98","repo":"grpc/grpc-go","slug":"failed-to-start-logging-v","errorCode":null,"errorMessage":"failed to start logging: %v","messagePattern":"failed to start logging: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gcp/observability/observability.go","lineNumber":76,"sourceCode":"\tif err = ensureProjectIDInObservabilityConfig(ctx, config); err != nil {\n\t\treturn err\n\t}\n\n\t// Cleanup any created resources this function created in case this function\n\t// errors.\n\tdefer func() {\n\t\tif err != nil {\n\t\t\tEnd()\n\t\t}\n\t}()\n\n\t// Enabling tracing and metrics via OpenCensus\n\tif err = startOpenCensus(config); err != nil {\n\t\treturn fmt.Errorf(\"failed to instrument OpenCensus: %v\", err)\n\t}\n\n\tif err = startLogging(ctx, config); err != nil {\n\t\treturn fmt.Errorf(\"failed to start logging: %v\", err)\n\t}\n\n\t// Logging is controlled by the config at methods level.\n\treturn nil\n}\n\n// End is the clean-up API for gRPC Observability plugin. It is expected to be\n// invoked in the main function of the application. The suggested usage is\n// \"defer observability.End()\". This function also flushes data to upstream, and\n// cleanup resources.\n//\n// Note: this method should only be invoked once.\nfunc End() {\n\tstopLogging()\n\tstopOpenCensus()\n}\n","sourceCodeStart":58,"sourceCodeEnd":93,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/gcp/observability/observability.go#L58-L93","documentation":"observability.Start called startLogging and it failed; the wrapped %v is error 252 (which itself wraps error 250, the Cloud Logging client error). Deferred End() runs to clean up. Emitted at observability.go:76.","triggerScenarios":"Config has a cloud_logging block but the Cloud Logging exporter could not be built or initialized. Same root causes as error 250/252: bad ADC, bad project, network blocked, API disabled.","commonSituations":"Same production-deploy failures as 250/252; surfaces here when only the top-level Start error is logged. Often accompanied by 254 if tracing/metrics are also enabled and ADC is the root cause.","solutions":["Diagnose the inner %v exactly as for error 250 (ADC, project_id, network, Cloud Logging API).","If logging is optional, remove cloud_logging from the config so Start proceeds without it.","Re-run Start in a fresh process after fixing credentials.","Log the full error chain so the underlying gcplogging.NewClient error is visible."],"exampleFix":"// before\n{\"project_id\":\"\",\"cloud_logging\":{}}\n\n// after\n{\"project_id\":\"my-proj\",\"cloud_logging\":{}}","handlingStrategy":"try-catch","validationCode":"// Reuse the error 250 pre-flight: ensure logging client builds before Start.\nif _, err := gcplogging.NewClient(ctx, \"projects/\"+projectID); err != nil {\n    return fmt.Errorf(\"logging unavailable; remove cloud_logging or fix env: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := observability.Start(ctx); err != nil {\n    if strings.Contains(err.Error(), \"failed to start logging\") {\n        log.Fatalf(\"logging subsystem failed to start (see inner exporter error): %v\", err)\n    }\n    return err\n}","preventionTips":["Make logging optional in your config schema so Start can proceed without it.","Surface the inner error from 250/252 in logs.","Re-run Start in a fresh process after fixing credentials."],"tags":["observability","cloud-logging","startup","gcp"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}