diff --git a/docs/content/observability/access-logs.md b/docs/content/observability/access-logs.md index 234204ed3..c09a8ebf4 100644 --- a/docs/content/observability/access-logs.md +++ b/docs/content/observability/access-logs.md @@ -35,7 +35,7 @@ If the given format is unsupported, the default (CLF) is used instead. !!! info "Common Log Format" ```html - - [] " " "" "" "" "" ms + - [] " " "" "" "" "" ms ``` ### `bufferingSize` @@ -195,6 +195,7 @@ accessLog: | `RequestMethod` | The HTTP method. | | `RequestPath` | The HTTP request URI, not including the scheme, host or port. | | `RequestProtocol` | The version of HTTP requested. | + | `RequestScheme` | The HTTP scheme requested `http` or `https`. | | `RequestLine` | `RequestMethod` + `RequestPath` + `RequestProtocol` | | `RequestContentSize` | The number of bytes in the request entity (a.k.a. body) sent by the client. | | `OriginDuration` | The time taken by the origin server ('upstream') to return its response. | diff --git a/pkg/middlewares/accesslog/logger_formatters.go b/pkg/middlewares/accesslog/logger_formatters.go index 5abb996d7..4c559a648 100644 --- a/pkg/middlewares/accesslog/logger_formatters.go +++ b/pkg/middlewares/accesslog/logger_formatters.go @@ -45,8 +45,8 @@ func (f *CommonLogFormatter) Format(entry *logrus.Entry) ([]byte, error) { toLog(entry.Data, "request_Referer", `"-"`, true), toLog(entry.Data, "request_User-Agent", `"-"`, true), toLog(entry.Data, RequestCount, defaultValue, true), - toLog(entry.Data, RouterName, defaultValue, true), - toLog(entry.Data, ServiceURL, defaultValue, true), + toLog(entry.Data, RouterName, `"-"`, true), + toLog(entry.Data, ServiceURL, `"-"`, true), elapsedMillis) return b.Bytes(), err diff --git a/pkg/middlewares/accesslog/logger_formatters_test.go b/pkg/middlewares/accesslog/logger_formatters_test.go index ce3c6aec5..79b2273f1 100644 --- a/pkg/middlewares/accesslog/logger_formatters_test.go +++ b/pkg/middlewares/accesslog/logger_formatters_test.go @@ -36,7 +36,7 @@ func TestCommonLogFormatter_Format(t *testing.T) { RouterName: "", ServiceURL: "", }, - expectedLog: `10.0.0.1 - Client [10/Nov/2009:23:00:00 +0000] "GET /foo http" - - "-" "-" 0 - - 123000ms + expectedLog: `10.0.0.1 - Client [10/Nov/2009:23:00:00 +0000] "GET /foo http" - - "-" "-" 0 "-" "-" 123000ms `, }, { diff --git a/pkg/middlewares/accesslog/logger_test.go b/pkg/middlewares/accesslog/logger_test.go index ad81c1c0b..3cf2e61b2 100644 --- a/pkg/middlewares/accesslog/logger_test.go +++ b/pkg/middlewares/accesslog/logger_test.go @@ -449,7 +449,7 @@ func TestNewLogHandlerOutputStdout(t *testing.T) { DefaultMode: "drop", }, }, - expectedLog: `- - - [-] "- - -" - - "testReferer" "testUserAgent" - - - 0ms`, + expectedLog: `- - - [-] "- - -" - - "testReferer" "testUserAgent" - "-" "-" 0ms`, }, { desc: "Default mode drop with override", @@ -464,7 +464,7 @@ func TestNewLogHandlerOutputStdout(t *testing.T) { }, }, }, - expectedLog: `- - TestUser [-] "- - -" - - "testReferer" "testUserAgent" - - - 0ms`, + expectedLog: `- - TestUser [-] "- - -" - - "testReferer" "testUserAgent" - "-" "-" 0ms`, }, { desc: "Default mode drop with header dropped", @@ -482,7 +482,7 @@ func TestNewLogHandlerOutputStdout(t *testing.T) { }, }, }, - expectedLog: `- - TestUser [-] "- - -" - - "-" "-" - - - 0ms`, + expectedLog: `- - TestUser [-] "- - -" - - "-" "-" - "-" "-" 0ms`, }, { desc: "Default mode drop with header redacted", @@ -500,7 +500,7 @@ func TestNewLogHandlerOutputStdout(t *testing.T) { }, }, }, - expectedLog: `- - TestUser [-] "- - -" - - "REDACTED" "REDACTED" - - - 0ms`, + expectedLog: `- - TestUser [-] "- - -" - - "REDACTED" "REDACTED" - "-" "-" 0ms`, }, { desc: "Default mode drop with header redacted", @@ -521,7 +521,7 @@ func TestNewLogHandlerOutputStdout(t *testing.T) { }, }, }, - expectedLog: `- - TestUser [-] "- - -" - - "REDACTED" "testUserAgent" - - - 0ms`, + expectedLog: `- - TestUser [-] "- - -" - - "REDACTED" "testUserAgent" - "-" "-" 0ms`, }, }