Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
http: Only log handler errors >= 500
Errors in the 4xx range are client errors, and they don't need to be entered into the server's error logs. 4xx errors are still recorded in the access logs at the error level.
Matthew Holt committed
Nov 4, 2019 at 12:18 UTC
d55fa68902519a4603565b15aea8ea31e454434c
1 file changed
+6
-2
modules/caddyhttp/server.go
+6
-2
@@ -152,7 +152,9 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
152
if err2 == nil {
153
// user's error route handled the error response
154
// successfully, so now just log the error
155
- logger.Error(errMsg, errFields...)
155
+ if errStatus >= 500 {
156
+ logger.Error(errMsg, errFields...)
157
+ }
158
} else {
159
// well... this is awkward
160
errFields = append([]zapcore.Field{
@@ -163,7 +165,9 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
165
logger.Error("error handling handler error", errFields...)
166
}
167
} else {
166
- logger.Error(errMsg, errFields...)
168
+ if errStatus >= 500 {
169
+ logger.Error(errMsg, errFields...)
170
+ }
171
w.WriteHeader(errStatus)
172
}
173
}