Go 1.11 has reached end of support
and will be deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Go 1.11
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Go
1.11 applications will continue to run and receive traffic after their
deprecation date. We
recommend that you migrate to the latest supported version of Go.
Package log provides the means of writing and querying an application's logs
from within an App Engine application.
Example:
c:=appengine.NewContext(r)query:=&log.Query{AppLogs:true,Versions:[]string{"1"},}forresults:=query.Run(c);;{record,err:=results.Next()iferr==log.Done{log.Infof(c,"Done processing results")break}iferr!=nil{log.Errorf(c,"Failed to retrieve next log: %v",err)break}log.Infof(c,"Saw record %v",record)}
Variables
Done
varDone=errors.New("log: query has no more results")
Done is returned when a query iteration has completed.
Debugf formats its arguments according to the format, analogous to fmt.Printf,
and records the text as a log message at Debug level. The message will be associated
with the request linked with the provided context.
typeQuerystruct{// Start time specifies the earliest log to return (inclusive).StartTimetime.Time// End time specifies the latest log to return (exclusive).EndTimetime.Time// Offset specifies a position within the log stream to resume reading from,// and should come from a previously returned Record's field of the same name.Offset[]byte// Incomplete controls whether active (incomplete) requests should be included.Incompletebool// AppLogs indicates if application-level logs should be included.AppLogsbool// ApplyMinLevel indicates if MinLevel should be used to filter results.ApplyMinLevelbool// If ApplyMinLevel is true, only logs for requests with at least one// application log of MinLevel or higher will be returned.MinLevelint// Versions is the major version IDs whose logs should be retrieved.// Logs for specific modules can be retrieved by the specifying versions// in the form "module:version"; the default module is used if no module// is specified.Versions[]string// A list of requests to search for instead of a time-based scan. Cannot be// combined with filtering options such as StartTime, EndTime, Offset,// Incomplete, ApplyMinLevel, or Versions.RequestIDs[]string}
[[["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-28 UTC."],[[["\u003cp\u003eThe \u003ccode\u003elog\u003c/code\u003e package in App Engine allows applications to write and query their logs, enabling developers to monitor application behavior and troubleshoot issues.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eQuery\u003c/code\u003e type allows for defining specific criteria for log retrieval, such as time ranges, versions, and log levels, making it flexible for diverse logging needs.\u003c/p\u003e\n"],["\u003cp\u003eLog messages can be recorded at different levels (Debug, Info, Warning, Error, Critical) using functions like \u003ccode\u003eDebugf\u003c/code\u003e, \u003ccode\u003eInfof\u003c/code\u003e, \u003ccode\u003eWarningf\u003c/code\u003e, \u003ccode\u003eErrorf\u003c/code\u003e, and \u003ccode\u003eCriticalf\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eRecord\u003c/code\u003e type contains detailed information about a single web request, including request times, status, latency, and associated application logs.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eDone\u003c/code\u003e variable indicates the end of a query iteration, signifying that no more log records are available.\u003c/p\u003e\n"]]],[],null,["# Package google.golang.org/appengine/log (v1.6.8)\n\nVersion latestkeyboard_arrow_down\n\n- [1.6.8 (latest)](/appengine/docs/legacy/standard/go111/reference/latest/log)\n- [1.6.7](/appengine/docs/legacy/standard/go111/reference/1.6.7/log) \n**Note:** To get more information about this package, such as access to older versions, view [this package on pkg.go.dev](https://pkg.go.dev/google.golang.org/appengine/log). \n\u003cbr /\u003e\n\nPackage log provides the means of writing and querying an application's logs\nfrom within an App Engine application.\n\nExample: \n\n```maple\nc := appengine.NewContext(r)\nquery := &log.Query{\n AppLogs: true,\n Versions: []string{\"1\"},\n}\n\nfor results := query.Run(c); ; {\n record, err := results.Next()\n if err == log.Done {\n log.Infof(c, \"Done processing results\")\n break\n }\n if err != nil {\n log.Errorf(c, \"Failed to retrieve next log: %v\", err)\n break\n }\n log.Infof(c, \"Saw record %v\", record)\n}\n``` \n\nVariables\n---------\n\n### Done\n\n var Done = https://pkg.go.dev/errors.https://pkg.go.dev/errors#New(\"log: query has no more results\")\n\nDone is returned when a query iteration has completed. \n\nFunctions\n---------\n\n### func Criticalf\n\n func Criticalf(ctx https://pkg.go.dev/context.https://pkg.go.dev/context#Context, format https://pkg.go.dev/builtin#string, args ...interface{})\n\nCriticalf is like Debugf, but at Critical level. \n\n### func Debugf\n\n func Debugf(ctx https://pkg.go.dev/context.https://pkg.go.dev/context#Context, format https://pkg.go.dev/builtin#string, args ...interface{})\n\nDebugf formats its arguments according to the format, analogous to fmt.Printf,\nand records the text as a log message at Debug level. The message will be associated\nwith the request linked with the provided context. \n\n### func Errorf\n\n func Errorf(ctx https://pkg.go.dev/context.https://pkg.go.dev/context#Context, format https://pkg.go.dev/builtin#string, args ...interface{})\n\nErrorf is like Debugf, but at Error level. \n\n### func Infof\n\n func Infof(ctx https://pkg.go.dev/context.https://pkg.go.dev/context#Context, format https://pkg.go.dev/builtin#string, args ...interface{})\n\nInfof is like Debugf, but at Info level. \n\n### func Warningf\n\n func Warningf(ctx https://pkg.go.dev/context.https://pkg.go.dev/context#Context, format https://pkg.go.dev/builtin#string, args ...interface{})\n\nWarningf is like Debugf, but at Warning level. \n\nAppLog\n------\n\n type AppLog struct {\n \tTime https://pkg.go.dev/time.https://pkg.go.dev/time#Time\n \tLevel https://pkg.go.dev/builtin#int\n \tMessage https://pkg.go.dev/builtin#string\n }\n\nAppLog represents a single application-level log. \n\nQuery\n-----\n\n type Query struct {\n \t// Start time specifies the earliest log to return (inclusive).\n \tStartTime https://pkg.go.dev/time.https://pkg.go.dev/time#Time\n\n \t// End time specifies the latest log to return (exclusive).\n \tEndTime https://pkg.go.dev/time.https://pkg.go.dev/time#Time\n\n \t// Offset specifies a position within the log stream to resume reading from,\n \t// and should come from a previously returned Record's field of the same name.\n \tOffset []https://pkg.go.dev/builtin#byte\n\n \t// Incomplete controls whether active (incomplete) requests should be included.\n \tIncomplete https://pkg.go.dev/builtin#bool\n\n \t// AppLogs indicates if application-level logs should be included.\n \tAppLogs https://pkg.go.dev/builtin#bool\n\n \t// ApplyMinLevel indicates if MinLevel should be used to filter results.\n \tApplyMinLevel https://pkg.go.dev/builtin#bool\n\n \t// If ApplyMinLevel is true, only logs for requests with at least one\n \t// application log of MinLevel or higher will be returned.\n \tMinLevel https://pkg.go.dev/builtin#int\n\n \t// Versions is the major version IDs whose logs should be retrieved.\n \t// Logs for specific modules can be retrieved by the specifying versions\n \t// in the form \"module:version\"; the default module is used if no module\n \t// is specified.\n \tVersions []https://pkg.go.dev/builtin#string\n\n \t// A list of requests to search for instead of a time-based scan. Cannot be\n \t// combined with filtering options such as StartTime, EndTime, Offset,\n \t// Incomplete, ApplyMinLevel, or Versions.\n \tRequestIDs []https://pkg.go.dev/builtin#string\n }\n\nQuery defines a logs query. \n\n### func (\\*Query) Run\n\n func (params *#google_golang_org_appengine_log_Query) Run(c https://pkg.go.dev/context.https://pkg.go.dev/context#Context) *#google_golang_org_appengine_log_Result\n\nRun starts a query for log records, which contain request and application\nlevel log information. \n\nRecord\n------\n\n type Record struct {\n \tAppID https://pkg.go.dev/builtin#string\n \tModuleID https://pkg.go.dev/builtin#string\n \tVersionID https://pkg.go.dev/builtin#string\n \tRequestID []https://pkg.go.dev/builtin#byte\n \tIP https://pkg.go.dev/builtin#string\n \tNickname https://pkg.go.dev/builtin#string\n \tAppEngineRelease https://pkg.go.dev/builtin#string\n\n \t// The time when this request started.\n \tStartTime https://pkg.go.dev/time.https://pkg.go.dev/time#Time\n\n \t// The time when this request finished.\n \tEndTime https://pkg.go.dev/time.https://pkg.go.dev/time#Time\n\n \t// Opaque cursor into the result stream.\n \tOffset []https://pkg.go.dev/builtin#byte\n\n \t// The time required to process the request.\n \tLatency https://pkg.go.dev/time.https://pkg.go.dev/time#Duration\n \tMCycles https://pkg.go.dev/builtin#int64\n \tMethod https://pkg.go.dev/builtin#string\n \tResource https://pkg.go.dev/builtin#string\n \tHTTPVersion https://pkg.go.dev/builtin#string\n \tStatus https://pkg.go.dev/builtin#int32\n\n \t// The size of the request sent back to the client, in bytes.\n \tResponseSize https://pkg.go.dev/builtin#int64\n \tReferrer https://pkg.go.dev/builtin#string\n \tUserAgent https://pkg.go.dev/builtin#string\n \tURLMapEntry https://pkg.go.dev/builtin#string\n \tCombined https://pkg.go.dev/builtin#string\n \tHost https://pkg.go.dev/builtin#string\n\n \t// The estimated cost of this request, in dollars.\n \tCost https://pkg.go.dev/builtin#float64\n \tTaskQueueName https://pkg.go.dev/builtin#string\n \tTaskName https://pkg.go.dev/builtin#string\n \tWasLoadingRequest https://pkg.go.dev/builtin#bool\n \tPendingTime https://pkg.go.dev/time.https://pkg.go.dev/time#Duration\n \tFinished https://pkg.go.dev/builtin#bool\n \tAppLogs []#google_golang_org_appengine_log_AppLog\n\n \t// Mostly-unique identifier for the instance that handled the request if available.\n \tInstanceID https://pkg.go.dev/builtin#string\n }\n\nRecord contains all the information for a single web request. \n\nResult\n------\n\n type Result struct {\n \t// contains filtered or unexported fields\n }\n\nResult represents the result of a query. \n\n### func (\\*Result) Next\n\n func (qr *#google_golang_org_appengine_log_Result) Next() (*#google_golang_org_appengine_log_Record, https://pkg.go.dev/builtin#error)\n\nNext returns the next log record,"]]