Usman Ismail
Usman Ismail

Reputation: 18679

How to log messages in GAE go runtime?

I am using the following simple code snippet to log messages in my application and during local testing I see all my logs.

However, I do not see any application logs when I deploy the app to GAE. Do I need to set logging properties anywhere? Or am I using the wrong logging library?

import (
    "log"
)

func Info(logMessage string, v ...interface{}) {
    if v != nil {
        log.Printf("[INFO]  "+logMessage, v)
    } else {
        log.Printf("[INFO]  " + logMessage)
    }
}

Upvotes: 3

Views: 188

Answers (2)

user7180
user7180

Reputation: 4096

In addition to deft_code 's answer:

The log will appear in the GAE console's log and color coded.

And I give you 2 lines of sample to start with:

appContext := appengine.NewContext(httpRequest)
appContext.Errorf("Couldn't send email: %v", err)

Upvotes: 1

deft_code
deft_code

Reputation: 59337

You should be using the app engine logging provided with the Context interface.
It provides several Debugf, Infof, Warningf, Errorf, and Criticalf.

Upvotes: 3

Related Questions