grpc/grpc-go · error
failed to start logging: %v
Error message
failed to start logging: %v
What it means
A wrapper returned by Start() when startLogging(ctx, config) fails. This is the Cloud Logging subsystem initialization (binary log sink setup). OpenCensus tracing/metrics have already succeeded by this point, but the logging collector could not be installed; Start() rolls back everything via the deferred End().
Source
Thrown at gcp/observability/observability.go:76
if err = ensureProjectIDInObservabilityConfig(ctx, config); err != nil {
return err
}
// Cleanup any created resources this function created in case this function
// errors.
defer func() {
if err != nil {
End()
}
}()
// Enabling tracing and metrics via OpenCensus
if err = startOpenCensus(config); err != nil {
return fmt.Errorf("failed to instrument OpenCensus: %v", err)
}
if err = startLogging(ctx, config); err != nil {
return fmt.Errorf("failed to start logging: %v", err)
}
// Logging is controlled by the config at methods level.
return nil
}
// End is the clean-up API for gRPC Observability plugin. It is expected to be
// invoked in the main function of the application. The suggested usage is
// "defer observability.End()". This function also flushes data to upstream, and
// cleanup resources.
//
// Note: this method should only be invoked once.
func End() {
stopLogging()
stopOpenCensus()
}
View on GitHub (pinned to 03255a9237)
Solutions
- Read the wrapped error to determine whether the failure is auth, network, or config parsing.
- Provide valid Application Default Credentials with the Logging Writer role.
- If you only need tracing/metrics, disable the cloud_logging section in the config to bypass logging init.
- Whitelist the Cloud Logging API endpoint in your firewall/proxy egress rules.
Example fix
// before
config: {"cloud_logging":{},"cloud_trace":{},"cloud_monitoring":{}}
// after (disable logging if you cannot satisfy its auth/egress requirements)
config: {"cloud_trace":{"sampling_rate":0.5},"cloud_monitoring":{}} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight: only enable cloud_logging if a Cloud Logging client can be built.
// (There is no public pre-check API; gate via config instead.)
if !loggingEnabled {
config.CloudLogging = nil // avoid the failing path entirely
} Try / catch
if err := observability.Start(ctx); err != nil {
if strings.Contains(err.Error(), "failed to start logging") {
// Retry with cloud_logging disabled so trace/metrics still work.
log.Printf("disabling cloud_logging due to init failure: %v", err)
}
} Prevention
- Grant the Logging Writer IAM role to the service account used by Start().
- Whitelist logging.googleapis.com in egress firewalls.
- Disable the cloud_logging section in dev environments that lack GCP credentials.
When it happens
Trigger: Enabling cloud_logging in the config while the environment cannot supply a usable Cloud Logging client (missing/invalid credentials, unreachable logging endpoint, bad project). Passing a config whose logging method filters are malformed.
Common situations: Local dev machine without GCP credentials but with cloud_logging enabled; restrictive network egress rules blocking logging.googleapis.com; service account missing roles/logging.logWriter.
Related errors
- unable to create CloudLogging exporter: %v
- failed to instrument OpenCensus: %v
- invalid method string: %v, err: %v
- error in clientRPCEvent method: %v
- error in serverRPCEvent method: %v
AI-assisted analysis of grpc/grpc-go@03255a9237 (2026-08-07).
Data as JSON: /api/errors/57818c140066ef98.
Report an issue: GitHub.