New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not display error log on AppEngine #630
Comments
@k2wanko |
@vishr Write to os.Stdout is not output in goapp serve.
|
Can you set output? |
Can output if use package main
import (
"net/http"
"google.golang.org/appengine"
aelog "google.golang.org/appengine/log"
"github.com/labstack/echo"
"github.com/labstack/echo/engine/standard"
"github.com/labstack/gommon/log"
)
func init() {
e := echo.New()
e.SetLogLevel(log.ERROR)
e.GET("/", func(c echo.Context) error {
ctx := appengine.NewContext(c.Request().(*standard.Request).Request)
err := echo.NewHTTPError(400, "BadRequest")
aelog.Errorf(ctx, "IndexError: %v", err)
return err
})
s := standard.New("")
s.SetHandler(e)
http.Handle("/", s)
}
func main() {
http.ListenAndServe(":8080", nil)
} log:
|
Would disabling logging and using a custom HTTPErrorHandler works? The issue is the Echo Logger interface is not compatible with app engine logger (which require a golang 1.6 Context). Echo need to either let a middleware set a Logger for each request or change the Logger interface methods to have a Echo Context parameter. |
To log the http error in app engine: package hello
import (
"net/http"
"github.com/labstack/echo"
"google.golang.org/appengine"
"google.golang.org/appengine/log"
)
func init() {
e := echo.New()
e.HTTPErrorHandler = GaeHTTPErrorHandler
e.GET("/", func(c echo.Context) error {
return echo.NewHTTPError(400, "BadRequest")
})
http.Handle("/", e)
}
// GaeHTTPErrorHandler decorates default error handler by logging HTTP error using appengine/log.
func GaeHTTPErrorHandler(err error, c echo.Context) {
ctx := appengine.NewContext(c.Request())
log.Errorf(ctx, "HTTP error: %s", err)
c.Echo().DefaultHTTPErrorHandler(err, c)
} |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Description
Does not display error log in Terminal and AppEngine console.
The solution is to replace to
google.golang.org/appengine/log
Expected behaviour
google.golang.org/appengine/log
Actual behaviour
github.com/labstack/gommon/log
log:
Steps to reproduce
Working code to debug
Version/commit
go version go1.6.2 (appengine-1.9.40) darwin/amd64
The text was updated successfully, but these errors were encountered: