Take a look here: http://github.com/gorilla/handlers
http.Handle("/foo", funcFoo)
err := http.ListenAndServe("127.0.0.1:2074", handlers.LoggingHandler(os.Stdout, http.DefaultServeMux))
This will log any incoming connections across the whole server. os.Stdout
can be replaced by anything that provides an io.Writer
(i.e. a file, a HTTP stream, etc). If you want it to be per-route, you can do:
http.Handle("/foo", handlers.LoggingHandler(os.Stdout, funcFoo))
It will also work with gorilla/mux and other routers/frameworks that are http.Handler compatible.