Write HTTP server logs into the global logger.

This commit is contained in:
Ludovic Fernandez 2019-09-09 14:52:04 +02:00 committed by Traefiker Bot
parent be90b20a5d
commit 25f4c23ab2

View file

@ -3,6 +3,7 @@ package server
import ( import (
"context" "context"
"fmt" "fmt"
stdlog "log"
"net" "net"
"net/http" "net/http"
"sync" "sync"
@ -16,10 +17,13 @@ import (
"github.com/containous/traefik/v2/pkg/middlewares/forwardedheaders" "github.com/containous/traefik/v2/pkg/middlewares/forwardedheaders"
"github.com/containous/traefik/v2/pkg/safe" "github.com/containous/traefik/v2/pkg/safe"
"github.com/containous/traefik/v2/pkg/tcp" "github.com/containous/traefik/v2/pkg/tcp"
"github.com/sirupsen/logrus"
"golang.org/x/net/http2" "golang.org/x/net/http2"
"golang.org/x/net/http2/h2c" "golang.org/x/net/http2/h2c"
) )
var httpServerLogger = stdlog.New(log.WithoutContext().WriterLevel(logrus.DebugLevel), "", 0)
type httpForwarder struct { type httpForwarder struct {
net.Listener net.Listener
connChan chan net.Conn connChan chan net.Conn
@ -352,7 +356,8 @@ func createHTTPServer(ln net.Listener, configuration *static.EntryPoint, withH2c
} }
serverHTTP := &http.Server{ serverHTTP := &http.Server{
Handler: handler, Handler: handler,
ErrorLog: httpServerLogger,
} }
listener := newHTTPForwarder(ln) listener := newHTTPForwarder(ln)