Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GAE Golang - log.Print()?

Tags:

Where can one read logs created by calling function:

log.Print("Message")

The tab "Logs" under Main seems to only display information about what URLs were called, but without any debug information that would be displayed by the application.

like image 477
ThePiachu Avatar asked Jan 31 '12 03:01

ThePiachu


2 Answers

As described in the documentation, you should use the Context interface to log instead of log, if you want your logs to show up in the console.

c := appengine.NewContext(r)
c.Infof("Requested URL: %v", r.URL)
like image 66
proppy Avatar answered Nov 02 '22 18:11

proppy


If you are using the new App Engine package google.golang.org/appengine, in the README:

  • Logging methods that were on appengine.Context are now functions in google.golang.org/appengine/log

So you should use

c := appengine.NewContext(r)
log.Infof(c, "Requested URL: %v", r.URL)
like image 42
Chunliang Lyu Avatar answered Nov 02 '22 17:11

Chunliang Lyu