Google App Engine flexible Log Handler

Logging handler for App Engine Flexible

Sends logs to the Cloud Logging API with the appropriate resource and labels for App Engine logs.

class google.cloud.logging_v2.handlers.app_engine.AppEngineHandler(client, *, name='app', transport=<class 'google.cloud.logging_v2.handlers.transports.background_thread.BackgroundThreadTransport'>, stream=None)

Bases: logging.StreamHandler

A logging handler that sends App Engine-formatted logs to Stackdriver.

  • Parameters

    • client (Client) – The authenticated Google Cloud Logging client for this handler to use.

    • name (Optional[str ]) – Name for the logger.

    • transport (Optional[Transport]) – The transport class. It should be a subclass of Transport. If unspecified, BackgroundThreadTransport will be used.

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

emit(record)

Actually log the specified logging record.

Overrides the default emit behavior of StreamHandler.

See https://docs.python.org/2/library/logging.html#handler-objects

get_gae_labels()

Return the labels for GAE app.

If the trace ID can be detected, it will be included as a label. Currently, no other labels are included.

  • Returns

    Labels for GAE app.

  • Return type

    dict

get_gae_resource()

Return the GAE resource using the environment variables.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月30日 UTC.