[DEPRECATED] Kubernetes Engine Handler

Deprecated: Deprecated since version 3.0.0: UseStructuredLogHandler instead.

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.

class google.cloud.logging_v2.handlers.container_engine.ContainerEngineHandler(*, name=None, stream=None)

Bases:logging.StreamHandler

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.

  • Parameters

    • name (Optional[str]) – The name of the custom log in Cloud Logging.

    • stream (Optional[IO]) – Stream to be used by the handler.

format(record)

Format the message into JSON expected by fluentd.

  • Parameters

    record (logging.LogRecord) – The log record.

  • Returns

    A JSON string formatted for GKE fluentd.

  • Return type

    str

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.