Python standardloggingFilter class to add Cloud Logging
information to each LogRecord.
When attached to a LogHandler, each incoming log will be modified
to include new Cloud Logging relevant data. This data can be manually
overwritten using theextrasargument when writing logs.
Logging handler for Google Container Engine (GKE).
Formats log messages in a JSON format, so that Kubernetes clusters with the
fluentd Google Cloud plugin installed can format their log messages so that
metadata such as log level is properly captured.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Package Classes (3.12.1)\n\nVersion latestkeyboard_arrow_down\n\n- [3.12.1 (latest)](/python/docs/reference/logging/latest/summary_class)\n- [3.12.0](/python/docs/reference/logging/3.12.0/summary_class)\n- [3.11.3](/python/docs/reference/logging/3.11.3/summary_class)\n- [3.10.0](/python/docs/reference/logging/3.10.0/summary_class)\n- [3.9.0](/python/docs/reference/logging/3.9.0/summary_class)\n- [3.8.0](/python/docs/reference/logging/3.8.0/summary_class)\n- [3.7.0](/python/docs/reference/logging/3.7.0/summary_class)\n- [3.6.0](/python/docs/reference/logging/3.6.0/summary_class)\n- [3.5.0](/python/docs/reference/logging/3.5.0/summary_class)\n- [3.4.0](/python/docs/reference/logging/3.4.0/summary_class)\n- [3.3.1](/python/docs/reference/logging/3.3.1/summary_class)\n- [3.2.5](/python/docs/reference/logging/3.2.5/summary_class)\n- [3.1.2](/python/docs/reference/logging/3.1.2/summary_class)\n- [3.0.0](/python/docs/reference/logging/3.0.0/summary_class)\n- [2.7.2](/python/docs/reference/logging/2.7.2/summary_class)\n- [2.6.0](/python/docs/reference/logging/2.6.0/summary_class)\n- [2.5.0](/python/docs/reference/logging/2.5.0/summary_class)\n- [2.4.0](/python/docs/reference/logging/2.4.0/summary_class)\n- [2.3.1](/python/docs/reference/logging/2.3.1/summary_class)\n- [2.2.0](/python/docs/reference/logging/2.2.0/summary_class)\n- [2.1.1](/python/docs/reference/logging/2.1.1/summary_class)\n- [2.0.2](/python/docs/reference/logging/2.0.2/summary_class)\n- [1.15.3](/python/docs/reference/logging/1.15.3/summary_class)\n- [1.14.0](/python/docs/reference/logging/1.14.0/summary_class)\n- [1.13.0](/python/docs/reference/logging/1.13.0/summary_class)\n- [1.12.1](/python/docs/reference/logging/1.12.1/summary_class) \nSummary of entries of Classes for logging. \n\nClasses\n-------\n\n### [Client](/python/docs/reference/logging/latest/google.cloud.logging_v2.client.Client)\n\nClient to bundle configuration needed for API requests.\n\n### [LogEntry](/python/docs/reference/logging/latest/google.cloud.logging_v2.entries.LogEntry)\n\nLog entry.\n\n### [ProtobufEntry](/python/docs/reference/logging/latest/google.cloud.logging_v2.entries.ProtobufEntry)\n\nLog entry with protobuf message payload.\n\n### [StructEntry](/python/docs/reference/logging/latest/google.cloud.logging_v2.entries.StructEntry)\n\nLog entry with JSON payload.\n\n### [TextEntry](/python/docs/reference/logging/latest/google.cloud.logging_v2.entries.TextEntry)\n\nLog entry with text payload.\n\n### [AppEngineHandler](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.app_engine.AppEngineHandler)\n\nA logging handler that sends App Engine-formatted logs to Stackdriver.\n\nDEPRECATED: use CloudLoggingHandler instead.\n\n### [ContainerEngineHandler](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.container_engine.ContainerEngineHandler)\n\nHandler to format log messages the format expected by GKE fluent.\n\nThis handler is written to format messages for the Google Container Engine\n(GKE) fluentd plugin, so that metadata such as log level are properly set.\n\nDEPRECATED: use StructuredLogHandler to write formatted logs to standard out instead.\n\n### [CloudLoggingFilter](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.handlers.CloudLoggingFilter)\n\nPython standard `logging` Filter class to add Cloud Logging\ninformation to each LogRecord.\n\nWhen attached to a LogHandler, each incoming log will be modified\nto include new Cloud Logging relevant data. This data can be manually\noverwritten using the `extras` argument when writing logs.\n\n### [CloudLoggingHandler](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.handlers.CloudLoggingHandler)\n\nHandler that directly makes Cloud Logging API calls.\n\nThis is a Python standard `logging` handler using that can be used to\nroute Python standard logging messages directly to the Stackdriver\nLogging API.\n\nThis handler is used when not in GAE or GKE environment.\n\nThis handler supports both an asynchronous and synchronous transport.\n\nExample: \n\n import logging\n import google.cloud.logging\n from google.cloud.logging_v2.handlers import https://cloud.google.com/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.handlers.CloudLoggingHandler.html\n\n client = google.cloud.logging.https://cloud.google.com/python/docs/reference/logging/latest/google.cloud.logging_v2.client.Client.html()\n handler = CloudLoggingHandler(client)\n\n cloud_logger = logging.getLogger('cloudLogger')\n cloud_logger.setLevel(logging.INFO)\n cloud_logger.addHandler(handler)\n\n cloud_logger.error('bad news') # API call\n\n### [StructuredLogHandler](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.structured_log.StructuredLogHandler)\n\nHandler to format logs into the Cloud Logging structured log format,\nand write them to standard output\n\n### [BackgroundThreadTransport](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.transports.background_thread.BackgroundThreadTransport)\n\nAsynchronous transport that uses a background thread.\n\n### [Transport](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.transports.base.Transport)\n\nBase class for Google Cloud Logging handler transports.\n\nSubclasses of `Transport` must have constructors that accept a\nclient and name object, and must override `send`.\n\n### [SyncTransport](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.transports.sync.SyncTransport)\n\nBasic sychronous transport.\n\nUses this library's Logging client to directly make the API call.\n\n### [Batch](/python/docs/reference/logging/latest/google.cloud.logging_v2.logger.Batch)\n\nContext manager: collect entries to log via a single API call.\n\nHelper returned by `Logger.batch`\n\n### [Logger](/python/docs/reference/logging/latest/google.cloud.logging_v2.logger.Logger)\n\nLoggers represent named targets for log entries.\n\nSee \u003chttps://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.logs\u003e\n\n### [Metric](/python/docs/reference/logging/latest/google.cloud.logging_v2.metric.Metric)\n\nMetrics represent named filters for log entries.\n\nSee\n\u003chttps://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics\u003e\n\n### [Resource](/python/docs/reference/logging/latest/google.cloud.logging_v2.resource.Resource)\n\nA monitored resource identified by specifying values for all labels.\n\n### [Sink](/python/docs/reference/logging/latest/google.cloud.logging_v2.sink.Sink)\n\nSinks represent filtered exports for log entries.\n\nSee \u003chttps://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks\u003e\n\nModules\n-------\n\n### [client](/python/docs/reference/logging/latest/google.cloud.logging_v2.client)\n\nClient for interacting with the Google Cloud Logging API.\n\n### [entries](/python/docs/reference/logging/latest/google.cloud.logging_v2.entries)\n\nLog entries within the Google Cloud Logging API.\n\n### [app_engine](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.app_engine)\n\nLogging handler for App Engine Flexible\n\nSends logs to the Cloud Logging API with the appropriate resource\nand labels for App Engine logs.\n\n### [container_engine](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.container_engine)\n\nLogging handler for Google Container Engine (GKE).\n\nFormats log messages in a JSON format, so that Kubernetes clusters with the\nfluentd Google Cloud plugin installed can format their log messages so that\nmetadata such as log level is properly captured.\n\n### [handlers](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.handlers)\n\nPython `logging` handlers for Cloud Logging.\n\n### [structured_log](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.structured_log)\n\nLogging handler for printing formatted structured logs to standard output.\n\n### [background_thread](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.transports.background_thread)\n\nTransport for Python logging handler\n\nUses a background worker to log to Cloud Logging asynchronously.\n\n### [base](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.transports.base)\n\nModule containing base class for logging transport.\n\n### [sync](/python/docs/reference/logging/latest/google.cloud.logging_v2.handlers.transports.sync)\n\nTransport for Python logging handler.\n\nLogs directly to the Cloud Logging API with a synchronous call.\n\n### [logger](/python/docs/reference/logging/latest/google.cloud.logging_v2.logger)\n\nDefine API Loggers.\n\n### [metric](/python/docs/reference/logging/latest/google.cloud.logging_v2.metric)\n\nDefine Cloud Logging API Metrics.\n\n### [resource](/python/docs/reference/logging/latest/google.cloud.logging_v2.resource)\n\nMonitored Resource for the Google Logging API V2.\n\n### [sink](/python/docs/reference/logging/latest/google.cloud.logging_v2.sink)\n\nDefine Cloud Logging API Sinks."]]