浏览代码

lib/api: Don't log random stuff in the HTTP server (fixes #5738) (#5897)

Jakob Borg 6 年之前
父节点
当前提交
159d1a68e1
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      lib/api/api.go

+ 4 - 0
lib/api/api.go

@@ -13,6 +13,7 @@ import (
 	"fmt"
 	"io"
 	"io/ioutil"
+	"log"
 	"net"
 	"net/http"
 	"net/url"
@@ -337,6 +338,9 @@ func (s *service) serve(stop chan struct{}) {
 		// ReadTimeout must be longer than SyncthingController $scope.refresh
 		// interval to avoid HTTP keepalive/GUI refresh race.
 		ReadTimeout: 15 * time.Second,
+		// Prevent the HTTP server from logging stuff on its own. The things we
+		// care about we log ourselves from the handlers.
+		ErrorLog: log.New(ioutil.Discard, "", 0),
 	}
 
 	l.Infoln("GUI and API listening on", listener.Addr())