In appengine you have to use google.golang.org/appengine/log package. The log calls must have a context passed to it.
See https://cloud.google.com/appengine/docs/standard/go/logs/reference. On Friday, November 3, 2017 at 3:58:34 AM UTC-4, Sankar wrote: > > Hi > > > I have a golang file where I have code like: > > > log.Fatal("My error message: ", err) > > > When the above statement is executed, In the appengine logviewer, I get > something like: > > panic: os.Exit called goroutine 1 [running]: > os.Exit(0x1) > go/src/os/proc.go:58 > <https://console.cloud.google.com/debug/fromlog?appModule=default&appVersion=20171103t130151&file=go%2Fsrc%2Fos%2Fproc.go&line=58&logInsertId=59fc1ca5000391bb3a15d19c&logNanos=1509694618092435000&nestedLogIndex=0&project=celtic-facility-184703> > > +0x7c log.Fatal(0xc008549f60, 0x2, 0x2) > go/src/log/log.go:303 > <https://console.cloud.google.com/debug/fromlog?appModule=default&appVersion=20171103t130151&file=go%2Fsrc%2Flog%2Flog.go&line=303&logInsertId=59fc1ca5000391bb3a15d19c&logNanos=1509694618092435000&nestedLogIndex=0&project=celtic-facility-184703> > > +0x79 main.main() > main.go:42 > <https://console.cloud.google.com/debug/fromlog?appModule=default&appVersion=20171103t130151&file=main.go&line=42&logInsertId=59fc1ca5000391bb3a15d19c&logNanos=1509694618092435000&nestedLogIndex=0&project=celtic-facility-184703> > > +0x201 > > But I dont get any error message. The main.go:42 corresponds to the > log.Fatal line in my code but I do not get to see the error message that is > printed as part of the log statement. > > I see that appengine package has a "Log" function which may print the > AppLogs such that they can be viewed from the Google Appengine log console > itself. > > My question is, can the golang default log package be somehow instructed > to redirect to appengine ? Something like: > > if env == "AppEngine" { > log.SetOutput(appengine.DefaultLogger) > } > > in my main file ? This way, I get to make my code not locked to google > cloud and also can deploy existing code which uses log already. > > Any pointers ? > > Thanks. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.