diff --git a/middleware/logger_config.go b/middleware/logger_config.go index 6b0e528..0e4bea8 100644 --- a/middleware/logger_config.go +++ b/middleware/logger_config.go @@ -12,6 +12,7 @@ type skipperFunc func(ctx context.Context) bool // RequestLoggerConfig Contains the options for the logger middleware // can be optionally be passed to the `New`. type RequestLoggerConfig struct { + Access bool IP bool Query bool MessageContextKeys []string @@ -77,6 +78,7 @@ type RequestLoggerConfig struct { // LogFunc and Skippers to nil as well. func DefaultLoggerConfig() *RequestLoggerConfig { return &RequestLoggerConfig{ + Access: true, IP: false, Query: true, RequestRawBody: true, diff --git a/middleware/request_logger.go b/middleware/request_logger.go index b4b28d8..d54f7e2 100644 --- a/middleware/request_logger.go +++ b/middleware/request_logger.go @@ -61,6 +61,9 @@ func (l *requestLoggerMiddleware) ServeHTTP(ctx context.Context) { if !work.IsDeferRecycle() { loggerPool.Put(freelog) } + if !l.config.Access { + return + } // no time.Since in order to format it well after endTime = time.Now()