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 Logs Viewer.
When your application handles a request, it can also
write its own logging messages to
stderr. These files are
automatically collected and can be viewed in the Logs Viewer. Only the most
recent entries to
stderr are retained, in order
to limit their size.
The request and application logs for your app are collected by a Cloud Logging agent and are kept for a maximum of 90 days, up to a maximum size of 1GB. If you want to store your logs for a longer period or store a larger size than 1GB, you can export your logs to Cloud Storage. You can also export your logs to Big Query and Pub/Sub for further processing.
Other logs are also available for your use. See Runtime logs for a listing of these.
In addition to App Engine-generated request logs, apps running in the flexible environment can write additional logs. The following are some of the logs that are configured by default:
|Log name||Payload type||Purpose|
||text||Information logged when setup fails. If your application fails to run, check this log.|
||text||Information from the Google Docker container publishing data to Cloud Monitoring.|
||text||Information logged on shutdown.|
||text||Standard output from your app.|
||text||Standard error from your container.|
||text||The VM syslog, outside of the Docker container.|
Writing application logs
Write your application logs using
stdout for output and
stderr for errors.
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.
To view logs written by apps running in the flexible environment, use the Logs Viewer:
Visit the Logs Viewer page in the Google Cloud Platform Console.
From the log type pulldown menu, pick the log type (
crash.log, etc.), that you want to view.
Use the desired filter to retrieve the logs you want to see. You can filter by various combinations of time, log level, module, and log filter label or regular expression.
Notice that labels are regular expressions for filtering the logs by logging fields. Valid labels include the following:
path:/foo.* useragent:.*Chrome.*gets logs for all requests to a path starting with
/foothat were issued from a Chrome browser.
A typical App Engine request log contains data in the Apache combined log format, along with some special App Engine fields, as shown in the following sample log:
192.0.2.0 test [27/Jun/2014:09:11:47 -0700] "GET / HTTP/1.1" 200 414 - "http://www.example.com/index.html" Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36" "1-dot-calm-sylph-602.appspot.com" ms=195 cpu_ms=42 cpm_usd=0.000046 loading_request=1 instance=00c61b117cfeb66f973d7df1b7f4ae1f064d app_engine_release=1.9.42
request_log log contents
The following table lists the fields in order of occurrence along with a description:
|Field Order||Field Name||Always Present?||Description|
|1||Client address||Yes||Client IP address. Example:
|2||RFC1413 identity||No||RFC1413 identity of the client. This is nearly always the character
|3||User||No||Present only if the app uses the Users API and the user is logged in. This value is the "nickname" portion of the Google Account, for example, if the Google Account is
|4||Timestamp||Yes||Request timestamp. Example:
|5||Request querystring||Yes||First line of the request, containing method, path, and HTTP version. Example:
|6||HTTP Status Code||Yes||Returned HTTP status code. Example:
|7||Response size||Yes||Response size in bytes. Example:
|8||Referrer path||No||If there is no referrer, the log contains no path, but only
|9||User-agent||Yes||Identifies the browser and operating system to the web server. Example:
|10||Hostname||Yes||The hostname used by the client to connect to the App Engine application. Example : (
|11||Wallclock time||Yes||Total clock time in milliseconds spent by App Engine on the request. This time duration does not include time spent between the client and the server running the instance of your application. Example:
|12||CPU milliseconds||Yes||CPU milliseconds required to fulfill the request. This is the number of milliseconds spent by the CPU actually executing your application code, expressed in terms of a baseline 1.2 GHz Intel x86 CPU. If the CPU actually used is faster than the baseline, the CPU milliseconds can be larger than the actual clock time defined above. Example:
|13||Exit code||No||Only present if the instance shut down after getting the request. In the format
|14||Estimated cost||Yes||Estimated cost of 1000 requests just like this one, in USD. Example:
|15||Queue name||No||The name of the task queue used. Only present if request used a task queue. Example:
|16||Task name||No||The name of the task executed in the task queue for this request. Only present if the request resulted in the queuing of a task. Example:
|17||Pending queue||No||Only present if a request spent some time in a pending queue. If there are many of these in your logs and/or the values are high, it might be an indication that you need more instances to serve your traffic. Example:
|18||Loading request||No||Only present if the request is a loading request. This means an instance had to be started up. Ideally, your instances should be up and healthy for as long as possible, serving large numbers of requests before being recycled and needing to be started again. Which means you shouldn't see too many of these in your logs. Example:
|19||Instance||Yes||Unique identifier for the instance that handles the request. Example:
|20||Version||Yes||The current App Engine release version used in production App Engine: 1.9.42|