Writing Application Logs

When a request is sent to your application running in App Engine, request and
response details are logged automatically, and can be viewed in the
Google Cloud Platform Console Stackdriver Logs Viewer.

The request and application logs for your app are collected by a
Stackdriver Logging agent.
See Quota Policy for the logs retention policy and for
the maximum size of log entries. 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.

Writing application logs

Important: An application log line must not exceed 8K bytes. Nothing exceeding
this limit will be shown in the Logs Viewer.

When your application handles a request, it can write its own logging messages
to stdout and stderr. Write your application logs using stdout for output
and stderr for errors. These files are automatically collected and can be
viewed in the Logs Viewer. Note that this does not provide log levels that you
can use for filtering in the Logs Viewer; however, the Logs Viewer does provide
other filtering, such as text, timestamp, etc. Only the most recent entries in
the Logs Viewer are retained in order to limit their size.

You can write log entries using the psrLogger method, which fetches a PSR-3
compliant logger: