App Engine maintains a log of messages that your application emits using the
loggingmodule from the Python standard library, as well as other messages printed to the standard error stream. App Engine also records each request in the log. Each log severity level has a fixed buffer size that controls the amount of log information you can access. Normally, you use logging features more at lower log levels; thus, the time window is smaller for log events at these levels.
To browse your app's logs of the last 90 days, you can also use the Logs page in the GCP Console.
Requesting the logs
For performing more detailed analysis of your application's logs, use the AppCfg tooling delivered with the standalone App Engine SDK to download the log data.
To download logs to a file named
mylogs.txt, use the following command:
appcfg.sh request_logs [DIRECTORY_PATH] mylogs.txt
To view all of the options for this command, run:
appcfg.sh help request_logs
By default, the command downloads log messages from the current calendar day, which starts at midnight Pacific Time. The default log severity level is INFO, which also includes logs for all higher levels but omits DEBUG level messages. The command overwrites the local log file. You can adjust the number of days, the minimum log level, and whether to overwrite or append to the local log file using command-line options.
You can limit the log messages that are downloaded to just those emitted during
request on a given domain name using the
--vhost=... option. You can use this
to download the logs for your live app using a G Suite domain or
http://your_app_id.appspot.com, excluding log messages emitted by versions you
are testing on URLs such as
http://2.latest.your_app_id.appspot.com. Or you
can use it to download just the log messages for a given test domain.