{"id":4031,"library":"grpc-google-logging-v2","title":"gRPC Low-Level Client for Google Cloud Logging API v2","description":"This library provides the low-level gRPC client for directly interacting with the Google Cloud Logging API v2. It is derived from the API's Interface Definition Language (IDL) and is generally *not* intended for direct use by application developers. For Python applications, the recommended way to interact with Google Cloud Logging is via the higher-level `google-cloud-logging` library, which offers a more idiomatic Python interface and integrates with the standard `logging` module. This `grpc-google-logging-v2` package is at version 0.11.1 and has been in an inactive development status since 2016.","status":"abandoned","version":"0.11.1","language":"en","source_language":"en","source_url":"https://github.com/googleapis/googleapis","tags":["grpc","google-cloud","logging","api-client","low-level","abandoned"],"install":[{"cmd":"pip install grpc-google-logging-v2","lang":"bash","label":"Install only if absolutely necessary; prefer `google-cloud-logging`"}],"dependencies":[{"reason":"Core gRPC library.","package":"grpcio","optional":false},{"reason":"Common protobuf definitions for Google APIs.","package":"googleapis-common-protos","optional":false}],"imports":[{"note":"This is the recommended high-level client from the `google-cloud-logging` library, which is preferred for application development.","symbol":"Client","correct":"from google.cloud import logging"},{"note":"Direct use of `grpc-google-logging-v2` is not recommended. If low-level gRPC interaction is strictly required, the client stub is typically accessed via `google.logging.v2.logging_pb2_grpc` (part of `google-cloud-logging`).","wrong":"from grpc_google_logging_v2 import LoggingServiceV2Client","symbol":"LoggingServiceV2Client","correct":"from google.logging.v2 import logging_pb2_grpc"},{"note":"If directly interacting with raw protobuf messages, these types are exposed via `google.logging.v2.logging_pb2` (part of `google-cloud-logging`).","symbol":"LogEntry","correct":"from google.logging.v2 import logging_pb2"}],"quickstart":{"code":"import logging\nimport os\nfrom google.cloud import logging as cloud_logging\n\n# Instantiates a client for the higher-level google-cloud-logging library\nclient = cloud_logging.Client()\n\n# This method sets up a handler on the root logger, routing all logs at\n# INFO level and higher to Cloud Logging.\n# It automatically detects the environment (e.g., Cloud Run, GKE) to\n# use the most efficient logging method (e.g., structured JSON to stdout).\nclient.setup_logging()\n\n# Use the standard Python logging library\nlogging.info(\"Hello from a Python standard logger!\")\nlogging.warning(\"This is a warning log message.\")\nlogging.error(\"An error occurred here!\")\n\n# To send structured data, log a dictionary or JSON-parsable string\n# The `extra` argument can also be used for structured fields\nlogging.info(\n    \"Structured log message\",\n    extra={\n        \"json_fields\": {\n            \"component\": \"my-app\",\n            \"requestId\": os.environ.get('REQUEST_ID', 'N/A'),\n            \"status\": \"success\",\n            \"latency_ms\": 123\n        }\n    }\n)\n\nprint(\"Logs sent to Google Cloud Logging via standard Python logging.\")\n# In local development, you'll see these logs in your console.\n# In a Google Cloud environment (e.g., Cloud Run, GKE), they will be\n# automatically ingested by Cloud Logging.","lang":"python","description":"This quickstart demonstrates how to use the recommended `google-cloud-logging` library to send logs to Google Cloud Logging, integrating with Python's standard `logging` module. The `setup_logging()` method automatically configures a handler, often routing structured JSON to stdout/stderr in Cloud environments for efficient ingestion. For direct interaction with the low-level `grpc-google-logging-v2` library, the process would be significantly more complex, involving manual gRPC channel management and protobuf message construction."},"warnings":[{"fix":"Migrate to the `google-cloud-logging` library, which is actively maintained and recommended for all new and existing projects.","message":"This library is marked with an \"Inactive\" development status (7 - Inactive) on PyPI, and its last release was in September 2016. It is no longer actively maintained.","severity":"breaking","affected_versions":"<=0.11.1"},{"fix":"Install and use `google-cloud-logging` (e.g., `pip install google-cloud-logging`) and refer to its official documentation for usage patterns.","message":"Application developers should almost always use the `google-cloud-logging` Python library (`pip install google-cloud-logging`) for interacting with Google Cloud Logging, not `grpc-google-logging-v2`. `google-cloud-logging` provides a user-friendly, idiomatic Python interface that integrates seamlessly with the standard `logging` module and handles the underlying gRPC communication.","severity":"gotcha","affected_versions":"*"},{"fix":"Upgrade to the `google-cloud-logging` library, which supports modern Python versions.","message":"The last release of `grpc-google-logging-v2` officially supported Python 2.7, 3.4, and 3.5. Using it directly with modern Python versions (3.6+) may lead to compatibility issues or unexpected behavior due to lack of maintenance.","severity":"breaking","affected_versions":">=0.11.1 (when used with Python 3.6+)"},{"fix":"Utilize the higher-level abstractions provided by the `google-cloud-logging` library, which handles these complexities internally.","message":"`grpc-google-logging-v2` is a low-level, generated gRPC client. Direct usage requires deep understanding of gRPC, Protocol Buffers (especially `google.logging.v2.logging_pb2` and `logging_pb2_grpc`), and manual client stub management, which is significantly more complex than using `google-cloud-logging`.","severity":"gotcha","affected_versions":"*"},{"fix":"Always use `google.cloud.logging.Client().setup_logging()` when integrating the Python standard `logging` module with Google Cloud Logging via the `google-cloud-logging` library. This ensures correct severity mapping and structured logging.","message":"When not using `google-cloud-logging`'s `setup_logging()` for integration, standard Python `logging.info()` calls might appear with incorrect (e.g., `ERROR`) severity in Cloud Logging, as the default behavior for raw stdout/stderr ingestion might not correctly map Python logging levels.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}