summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-11-04 12:18:01 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2019-11-04 12:18:01 -0700
commitd55fa68902519a4603565b15aea8ea31e454434c (patch)
treebbe0949c6fc628b3a75dec1506bf63755d29ade0 /modules
parentb1f41d0ff1ee3e227d1d6e40ff7e215a2280dba2 (diff)
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.
Diffstat (limited to 'modules')
-rw-r--r--modules/caddyhttp/server.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go
index d01eaed..2d9d827 100644
--- a/modules/caddyhttp/server.go
+++ b/modules/caddyhttp/server.go
@@ -152,7 +152,9 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if err2 == nil {
// user's error route handled the error response
// successfully, so now just log the error
- logger.Error(errMsg, errFields...)
+ if errStatus >= 500 {
+ logger.Error(errMsg, errFields...)
+ }
} else {
// well... this is awkward
errFields = append([]zapcore.Field{
@@ -163,7 +165,9 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
logger.Error("error handling handler error", errFields...)
}
} else {
- logger.Error(errMsg, errFields...)
+ if errStatus >= 500 {
+ logger.Error(errMsg, errFields...)
+ }
w.WriteHeader(errStatus)
}
}