Skip to content
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

Logging in the v1.11 runtime #176

Closed
dchenk opened this issue Nov 20, 2018 · 13 comments
Closed

Logging in the v1.11 runtime #176

dchenk opened this issue Nov 20, 2018 · 13 comments
Labels
bankrupt Feel free to reopen when necessary.

Comments

@dchenk
Copy link

dchenk commented Nov 20, 2018

Issue #154 raises the question of structured logging in general, but it needs to be established what is the correct and recommended way to log messages at the various log levels (Critical/Error/Info, etc.) in the second generation standard environment Go 1.11 runtime. Official documentation here lists the google.golang.org/appengine/log package among the packages that "have been superseded by the Go standard library packages listed below"; instead the standard library "log" package is listed.

The sample app now also uses the standard "log" package.

Yet the appengine/log package does not contain any indication that the package is deprecated for the Go 1.11 runtime. Is it, really? If not, is any additional authentication step needed to use the package now within an app?

How must we now log errors distinctly from info or debug log entries?

@camstuart
Copy link

I use github.com/op/go-logging and so far messages seem to come out quite nicely in stackdriver:

If you would like an example, let me know

@apstndb
Copy link
Contributor

apstndb commented Nov 21, 2018

You can still use google.golang.org/appengine/log in Go 1.11 if you need it.

@apstndb
Copy link
Contributor

apstndb commented Nov 21, 2018

Related to this issue,
google.golang.org/appengine/log emit log for each line to stderr other than request_log.
https://github.com/golang/appengine/blob/v1.3.0/internal/api.go#L582

It seems too noisy and useless without structured logging.
I am currently set exclusion of stderr log to save the billing of Stackdriver Logging.

@dchenk
Copy link
Author

dchenk commented Nov 22, 2018

@apstndb thank you for that. I was able to figure out to use appengine.Main.

Googlers maintaining this project: I suggest that the docs here, which show this example, are changed to state that the recommended way to run an app in go111 is to call appengine.Main and use google.golang.org/appengine/log instead of the stdlib log package. That is, the docs should specify that this is the right approach if you want the same logging functionality that you had in Go runtime 1st generation.

@sbuss
Copy link
Contributor

sbuss commented Dec 1, 2018

I suggest that the docs [...] are changed to state that the recommended way to run an app in go111 is to call appengine.Main and use google.golang.org/appengine/log instead of the stdlib log package

The recommended way is not to use google.golang.org/appengine, but instead use stackdriver logging. github.com/op/go-logging looks promising, too!

@dchenk
Copy link
Author

dchenk commented Dec 1, 2018

Hi @sbuss
Are you speaking for Google there? Or is that something you were told or read somewhere? Honest question.

@apstndb
Copy link
Contributor

apstndb commented Dec 3, 2018

IMO, the "Migrating your App Engine app from Go 1.9 to Go 1.11" docs seems mainly for migrating to more open APIs rather than for migrating to Go 1.11 runtime.
It is mismatched with the document title and confusing.

I think that many users want to use Go 1.11 and want to get benefits of 2nd gen runtime as soon as possible but want to stay to use App Engine API unless their migration plan is ready.
It is making sense to separate the document, for migrating to 1.11 from 1st gen and for migrating to more open APIs from App Engine APIs.

@hazcod
Copy link

hazcod commented Jan 13, 2019

Has anything been done for documenting this?

@oyvindsk
Copy link

Anything happening on the logging issue? Not having log messages grouped by request makes the logging almost useless and is a huge regression from AE standard 1st gen runtimes. (Along with many, many others)

It works in 1.11 since you can still use google.golang.org/appengine/log but, according to the docs, it will not work in the future :'(

@mtraver
Copy link
Contributor

mtraver commented Sep 19, 2019

You can use the Stackdriver Logging API to group logs by request. Here's an example of how to do so: https://github.com/mtraver/gaelog

@iamacarpet
Copy link

Alternatively, instead of writing the logs to the Stackdriver API synchronously which can be slow, App Engine allows you to write out to virtual "files" that automatically get passed to Stackdriver in the background.

It is less well written than the one from @mtraver I'm afraid, but feel free to try this one: https://github.com/a1comms/go-gaelog

@evmar
Copy link

evmar commented Jun 19, 2020

I just wanted to comment on this bug to ensure it isn't lost. To summarize, there appear to be three different 'official' logging packages (Go, appengine, stackdriver) and no clear recommendation between them.

@derat
Copy link

derat commented Apr 22, 2022

This is an old bug, but just to save others some trouble: I think that structured logging (almost) works using the google.golang.org/appengine/v2/log package now, as long as you're using the standard environment. It looks like there was a typo in a header name that was fixed by #263, though, so you may need to run go get google.golang.org/appengine/v2@e0054249252f2a095b5f75c417b41d7cef9cbd10 instead of using the v2.0.1 release. Log entries are grouped by request for me with the go115 runtime.

@jinglundong jinglundong added the bankrupt Feel free to reopen when necessary. label May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bankrupt Feel free to reopen when necessary.
Projects
None yet
Development

No branches or pull requests