GAX Google Logging v2
raw JSON → 0.8.3 verified Fri May 01 auth: no python deprecated
This library provides a low-level, auto-generated client library (gRPC/HTTP) for the Google Cloud Logging API, generated from the googleapis protobuf definitions. Version 0.8.3 is the final release; it has been superseded by google-cloud-logging. No longer maintained.
pip install gax-google-logging-v2==0.8.3 Common errors
error ModuleNotFoundError: No module named 'gax_google_logging_v2' ↓
cause Incorrect import path: package name is gax-google-logging-v2 but import uses underscores and the actual modules are under google.logging.
fix
Use 'from google.logging.v2 import ...'.
error AttributeError: module 'google.logging.v2' has no attribute 'LogEntry' ↓
cause LogEntry is in the submodule google.logging.v2.log_entry.
fix
Use 'from google.logging.v2.log_entry import LogEntry'.
error TypeError: write_log_entries() missing 1 required positional argument: 'entries' ↓
cause The LoggingServiceV2Client in this GAX library expects a WriteLogEntriesRequest object or specific positional args, not the short form from google-cloud-logging.
fix
Use google-cloud-logging or construct a WriteLogEntriesRequest manually. Example:
from google.logging.v2.logging import WriteLogEntriesRequest
request = WriteLogEntriesRequest(log_name='...', entries=[...])
client.write_log_entries(request)
Warnings
deprecated This library is deprecated in favor of google-cloud-logging. Do not use for new projects. ↓
fix Use google-cloud-logging (pip install google-cloud-logging) instead.
breaking The package name on PyPI (gax-google-logging-v2) does not match the import path (google.logging.v2). Many users mistakenly attempt to import from gax_google_logging_v2. ↓
fix Use 'from google.logging.v2 import ...'.
gotcha This library only provides GAX (gRPC API eXtension) classes; it does not include any high-level client (like google.cloud.logging.Client). You must manually set up credentials, channels, and handle pagination. ↓
fix For a user-friendly client, use google-cloud-logging.
deprecated The google.logging.v2.LoggingServiceV2Client's write_log_entries method may not exist in this library; it was part of a higher-level client. The GAX library exposes the RPC stubs but may require manual proto packaging. ↓
fix Use google-cloud-logging to write log entries, or manually call the generated stub with a properly constructed WriteLogEntriesRequest.
Imports
- LoggingServiceV2Client wrong
from gax_google_logging_v2 import LoggingServiceV2Clientcorrectfrom google.logging.v2 import LoggingServiceV2Client - LogEntry wrong
from google.logging.v2 import LogEntrycorrectfrom google.logging.v2.log_entry import LogEntry
Quickstart
from google.logging.v2 import LoggingServiceV2Client
from google.logging.v2.log_entry import LogEntry
from google.logging.type import LogSeverity
client = LoggingServiceV2Client()
entry = LogEntry(
log_name='projects/my-project/logs/test',
resource={'type': 'global'},
severity=LogSeverity.INFO,
text_payload='Hello, world!'
)
# Writing via deprecated API - does not support write_log_entries directly
# Use google-cloud-logging instead
print('Client created successfully')