Package Classes (3.12.1) Stay organized with collections Save and categorize content based on your preferences.
Summary of entries of Classes for logging.
Classes
Client
Client to bundle configuration needed for API requests.
LogEntry
Log entry.
ProtobufEntry
Log entry with protobuf message payload.
StructEntry
Log entry with JSON payload.
TextEntry
Log entry with text payload.
AppEngineHandler
A logging handler that sends App Engine-formatted logs to Stackdriver.
DEPRECATED: use CloudLoggingHandler instead.
ContainerEngineHandler
Handler to format log messages the format expected by GKE fluent.
This handler is written to format messages for the Google Container Engine(GKE) fluentd plugin, so that metadata such as log level are properly set.
DEPRECATED: use StructuredLogHandler to write formatted logs to standard out instead.
CloudLoggingFilter
Python standardlogging Filter class to add Cloud Logginginformation to each LogRecord.
When attached to a LogHandler, each incoming log will be modifiedto include new Cloud Logging relevant data. This data can be manuallyoverwritten using theextras argument when writing logs.
CloudLoggingHandler
Handler that directly makes Cloud Logging API calls.
This is a Python standardlogging handler using that can be used toroute Python standard logging messages directly to the StackdriverLogging API.
This handler is used when not in GAE or GKE environment.
This handler supports both an asynchronous and synchronous transport.
Example:
import loggingimport google.cloud.loggingfrom google.cloud.logging_v2.handlers importCloudLoggingHandlerclient = google.cloud.logging.Client()handler = CloudLoggingHandler(client)cloud_logger = logging.getLogger('cloudLogger')cloud_logger.setLevel(logging.INFO)cloud_logger.addHandler(handler)cloud_logger.error('bad news') # API callStructuredLogHandler
Handler to format logs into the Cloud Logging structured log format,and write them to standard output
BackgroundThreadTransport
Asynchronous transport that uses a background thread.
Transport
Base class for Google Cloud Logging handler transports.
Subclasses ofTransport must have constructors that accept aclient and name object, and must overridesend.
SyncTransport
Basic sychronous transport.
Uses this library's Logging client to directly make the API call.
Batch
Context manager: collect entries to log via a single API call.
Helper returned byLogger.batch
Logger
Loggers represent named targets for log entries.
Seehttps://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.logs
Metric
Metrics represent named filters for log entries.
Seehttps://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics
Resource
A monitored resource identified by specifying values for all labels.
Sink
Sinks represent filtered exports for log entries.
Seehttps://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks
Modules
client
Client for interacting with the Google Cloud Logging API.
entries
Log entries within the Google Cloud Logging API.
app_engine
Logging handler for App Engine Flexible
Sends logs to the Cloud Logging API with the appropriate resourceand labels for App Engine logs.
container_engine
Logging handler for Google Container Engine (GKE).
Formats log messages in a JSON format, so that Kubernetes clusters with thefluentd Google Cloud plugin installed can format their log messages so thatmetadata such as log level is properly captured.
handlers
Pythonlogging handlers for Cloud Logging.
structured_log
Logging handler for printing formatted structured logs to standard output.
background_thread
Transport for Python logging handler
Uses a background worker to log to Cloud Logging asynchronously.
base
Module containing base class for logging transport.
sync
Transport for Python logging handler.
Logs directly to the Cloud Logging API with a synchronous call.
logger
Define API Loggers.
metric
Define Cloud Logging API Metrics.
resource
Monitored Resource for the Google Logging API V2.
sink
Define Cloud Logging API Sinks.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-30 UTC.