A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/appengine/docs/flexible/dotnet/writing-application-logs below:

Write and view logs | Google App Engine flexible environment docs

Write and view logs

Stay organized with collections Save and categorize content based on your preferences.

This page describes the logs that are available for App Engine apps, and how to write, correlate, and view log entries.

App Engine collects two types of logs:

App Engine automatically sends both the request logs and app logs to the Cloud Logging agent.

Write app logs

App Engine automatically emits logs for requests sent to your app, so there is no need to write request logs. This section covers how to write app logs.

When you write app logs from your App Engine app, the logs are picked up automatically by Cloud Logging, as long as the logs are written using the following methods:

Integrate with Cloud Logging

You can integrate your App Engine app with Cloud Logging. This approach lets you use all the features offered by Cloud Logging and requires only a few lines of Google-specific code.

Important: The Logs Explorer does not display an app log entry that exceeds 16 kilobytes. Write structured logs to stdout and stderr

By default, App Engine uses the Cloud Logging client library to send logs. However, this method doesn't support structured logging. You can only write structured logs using stdout/stderr. Additionally, you can also send text strings to stdout and stderr. By default, the log payload is a text string stored in the textPayload field of the log entry. The strings appear as messages in the Logs Explorer, the command line, and the Cloud Logging API, and are associated with the App Engine service and version that emitted them.

To get more value from the logs, you can filter these strings in the Logs Explorer by severity level. To filter these strings, you need to format the strings as structured data. To do this, you write logs in the form of a single line of serialized JSON. App Engine picks up and parses this serialized JSON line, and places it into the jsonPayload field of the log entry instead of textPayload.

The stdout and stderr logs from the flexible environment are sent to Cloud Logging using the legacy logging agent running in the virtual machine instances. The logging agent runs with limited resources and the logs that are written are rotated after exceeding a 10 MB limit. If the rate at which logs are written to stdout and stderr is greater than the rate at which logs are read by the logging agent, the logs can get rotated before the logs are sent to Cloud Logging. If you don't want to lose logs, use Cloud Logging.

Special JSON fields in messages

When you provide a structured log as a JSON dictionary, some special fields are stripped from the jsonPayload and are written to the corresponding field in the generated LogEntry as described in the documentation for special fields.

For example, if your JSON includes a severity property, it is removed from the jsonPayload and appears instead as the log entry's severity. The message property is used as the main display text of the log entry if present.

Correlate request logs with app logs

After you've formatted the entries as a JSON object and provided specific metadata, you can enable filtering and correlation with request logs. To correlate the request log entries with the app log entries, you need the request's trace identifier. Follow the instructions to correlate log messages:

  1. Extract the trace identifier from the X-Cloud-Trace-Context request header.
  2. In your structured log entry, write the ID to a field named logging.googleapis.com/trace. For more information about the X-Cloud-Trace-Context header, see Forcing a request to be traced.

To view correlated logs, see View correlated log entries in the Logs Explorer.

View logs

You can view app logs and request logs in several ways:

Use Logs Explorer

You can view your app and request logs using the Logs Explorer:

  1. Go to Logs Explorer in the Google Cloud console:

    Go to Logs Explorer

  2. Select an existing Google Cloud project at the top of the page.

  3. In Resource Type, select GAE Application.

You can filter the Logs Explorer by App Engine service, version and other criteria. You can also search the logs for specific entries. See Using the Logs Explorer for details.

If you send simple text entries to standard output, you cannot use the Logs Viewer to filter app entries by severity, nor can you see which app logs correspond to specific requests. You can still use other types of filtering in the Logs Explorer, such as text and timestamp.

In the Logs Explorer, to view the child log entries correlated with a parent log entry, expand the log entry.

For example, to display your App Engine request log entry and application log entries, do the following:

  1. In the navigation panel of the Google Cloud console, select Logging, and then select Logs Explorer:

    Go to Logs Explorer

  2. In Resource Type, select GAE Application.

  3. To view and correlate request logs, in Log Name, select request_log. Alternatively, to correlate by request logs, click Correlate by and select request_log.

  4. In the Query results pane, to expand a log entry, click Expand. On expanding, each request log will show the associated app logs.

After creating a filter for the logs, each request log shows corresponding app logs as child logs. Logs Explorer achieves this by correlating the trace field in app logs and a given request log, assuming the application uses the google-cloud-logging library.

The following image shows app logs grouped by the trace field:

Use the Google Cloud CLI

To view your App Engine logs from the command line, use the following command:

gcloud app logs tail

For more information, see gcloud app logs tail.

Reading logs programmatically

If you want to read the logs programmatically, you can use one of these methods:

Pricing, quotas, and logs retention policy

For information about pricing that applies to both request and app logs, see Pricing for Cloud Logging.

For the logs retention policy and the maximum size of log entries, see Quotas and limits. If you want to store your logs for a longer period, you can export your logs to Cloud Storage. You can also export your logs to BigQuery and Pub/Sub for further processing.

Managing log resource usage

You can control the amount of logging activity from your app logs by writing more or fewer entries from your app's code. Request logs are created automatically, so to manage the number of request log entries associated with your app, Use the logs exclusion feature from Cloud Logging.

Known issues

The following are some logging issues in the second-generation runtimes:

What's next

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-08-07 UTC.

[[["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-07 UTC."],[[["App Engine captures both request logs (HTTP requests to the app) and app logs (entries written by the application)."],["App logs can be written using Cloud Logging integration or by outputting structured logs to `stdout` and `stderr`."],["Structured logs in JSON format enable enhanced filtering and correlation with request logs in the Logs Explorer."],["Logs can be viewed and analyzed via the Logs Explorer, the Google Cloud CLI, or programmatically through the Cloud Logging API."],["The logs can be managed, and the costs associated with logging can be managed by using logs exclusion feature and exporting logs."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4