Google Container Engine Log Handler#

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.


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.

Initialize the handler.

If stream is not specified, sys.stderr is used.


Format the message into JSON expected by fluentd.

Parameters:record (LogRecord) – the log record
Return type:str
Returns:A JSON string formatted for GKE fluentd.