logging - Can only access request-logs from Google App Engine golang application -
i have gae golang application has logging statements like:
func logdebugmessage(req *http.request) { context := appengine.newcontext(req) c.debugf("#%d debugging here.", 1) }
how can access logging messages generated c.debugf
call?
the appcfg.py request_logs
, gae console (https://console.developers.google.com/project/.../logs
) both appear have http request logs.
is there tool request logs generated gae context?
there 2 kinds of logs: request logs generated automatically platform requests , contains request details (like timestamp, client ip, user agent, status codes, serving time, instance id etc.) , application logs result of context.debugf()
, context.warningf()
, context.infof()
, context.errorf()
, context.criticalf()
method calls.
application logs attached (or associated with) requests (request log records), requests called (during serving requests).
request (and application) logs can viewed on logs page of admin console or on developer console. both admin console , developer console display both request , application log records. note on both admin , developer console have click on log records expand them. once expand request log, application log records displayed done request.
if want download application logs well, can specify --include_all
parameter appcfg.py
tool.
programatically can query request logs, see logs go api overview more details. here log package reference.
when query request logs, result log.record
values. struct
contains applogs
field slice of log.applog
. applog
type (it's struct
) descirbes application log made e.g. context.debugf()
call.
the applog
type looks this:
type applog struct { time time.time level int message string }
the message
string
result of formatted log message.
here example how query log records including application logs:
c := appengine.newcontext(r) query := &log.query{ applogs: true, versions: []string{"1"}, } results := query.run(c); ; { record, err := results.next() if err == log.done { c.infof("done processing results") break } if err != nil { c.errorf("failed retrieve next log: %v", err) break } // record // process application logs: _, ap := range record.applogs { msg := ap.message // msg application log text message } }
Comments
Post a Comment