Closed
Description
This is a feature request. I'm trying to implement Apache-style logging in my program, using camlistore's logging.go as an example: http://camlistore.org/code/?p=camlistore.git;a=blob;f=website/logging.go;hb=HEAD While the code looks good, it hooks quite deeply into the http package's internals and requires too much knowledge to be called trivial. Perhaps an easier logging hook should be provided inside net/http/server.go in the Go standard library itself. Any thoughts?
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
bradfitz commentedon Mar 18, 2012
Comment 1:
Labels changed: added priority-later, featurerequest, removed priority-triage.
rsc commentedon Sep 12, 2012
Comment 2:
Status changed to Accepted.
rsc commentedon Sep 12, 2012
Comment 3:
Labels changed: added go1.1maybe.
robpike commentedon Mar 7, 2013
Comment 4:
Labels changed: removed go1.1maybe.
rsc commentedon Jul 30, 2013
Comment 5:
Labels changed: added go1.2maybe.
Owner changed to @bradfitz.
rsc commentedon Jul 30, 2013
Comment 6:
Labels changed: added feature.
robpike commentedon Aug 30, 2013
Comment 7:
Labels changed: removed go1.2maybe.
rsc commentedon Nov 27, 2013
Comment 8:
Labels changed: added go1.3maybe.
rsc commentedon Nov 27, 2013
Comment 9:
Labels changed: removed feature.
rsc commentedon Dec 4, 2013
Comment 10:
Labels changed: added release-none, removed go1.3maybe.
rsc commentedon Dec 4, 2013
Comment 11:
Labels changed: added repo-main.
9 remaining items
rakyll commentedon May 20, 2016
Is this issue still in the plans? We can hook a Logger to an http.Client and an http.Server.
bradfitz commentedon May 20, 2016
Update: Camlistore's logging code is now here: https://github.com/camlistore/camlistore/blob/master/website/logging.go
This bug is about an interface for the HTTP server to report back stats about a handler's activity after it's done, to let another layer serialize it or sent it off to logging somewhere.
This can be done with Handler wrappers (as in Camlistore's code, and done by many others), but the HTTP server knows much more and more efficiently, so it could just be built-in.
There are still no plans, but somebody could work on it. I'd be happy to review.
It would need to work with both HTTP/1 and HTTP/2.
A good place to put the stats records is the new https://tip.golang.org/pkg/net/http/httptrace/ package, to not pollute the main http package godoc.
tombergan commentedon Apr 24, 2017
This is now a dup of #18997. See the following comment:
#18997 (comment)