go-apachelog: github.com/cespare/go-apachelog Index | Files

package apachelog

import "github.com/cespare/go-apachelog"

Package apachelog is a library for logging the responses of an http.Handler in the Apache Common Log Format. It uses a variant of this log format (http://httpd.apache.org/docs/1.3/logs.html#common) also used by Rack::CommonLogger in Ruby. The format has an additional field at the end for the response time in seconds.

Using apachelog is typically very simple. You'll need to create an http.Handler and set up your request routing first. In a simple web application, for example, you might just use http.NewServeMux(). Next, wrap the http.Handler in an apachelog handler using NewHandler, create an http.Server with this handler, and you're good to go.


mux := http.NewServeMux()
mux.HandleFunc("/", handler)
loggingHandler := apachelog.NewHandler(mux, os.Stderr)
server := &http.Server{
	Addr: ":8899",
	Handler: loggingHandler,


Package Files



var ErrHijackingNotSupported = errors.New("hijacking is not supported")

func NewHandler

func NewHandler(h http.Handler, out io.Writer) http.Handler

NewHandler creates a new http.Handler, given some underlying http.Handler to wrap and an output stream (typically os.Stderr).

Package apachelog imports 7 packages (graph) and is imported by 2 packages. Updated 2015-05-09. Refresh now. Tools for package owners.