Access log field quotes.

This commit is contained in:
Ludovic Fernandez 2020-03-17 12:36:04 +01:00 committed by GitHub
parent b5d205b78c
commit 62c3025a76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 9 deletions

View file

@ -35,7 +35,7 @@ If the given format is unsupported, the default (CLF) is used instead.
!!! info "Common Log Format" !!! info "Common Log Format"
```html ```html
<remote_IP_address> - <client_user_name_if_available> [<timestamp>] "<request_method> <request_path> <request_protocol>" <origin_server_HTTP_status> <origin_server_content_size> "<request_referrer>" "<request_user_agent>" <number_of_requests_received_since_Traefik_started> "<Traefik_frontend_name>" "<Traefik_backend_URL>" <request_duration_in_ms>ms <remote_IP_address> - <client_user_name_if_available> [<timestamp>] "<request_method> <request_path> <request_protocol>" <origin_server_HTTP_status> <origin_server_content_size> "<request_referrer>" "<request_user_agent>" <number_of_requests_received_since_Traefik_started> "<Traefik_router_name>" "<Traefik_server_URL>" <request_duration_in_ms>ms
``` ```
### `bufferingSize` ### `bufferingSize`
@ -195,6 +195,7 @@ accessLog:
| `RequestMethod` | The HTTP method. | | `RequestMethod` | The HTTP method. |
| `RequestPath` | The HTTP request URI, not including the scheme, host or port. | | `RequestPath` | The HTTP request URI, not including the scheme, host or port. |
| `RequestProtocol` | The version of HTTP requested. | | `RequestProtocol` | The version of HTTP requested. |
| `RequestScheme` | The HTTP scheme requested `http` or `https`. |
| `RequestLine` | `RequestMethod` + `RequestPath` + `RequestProtocol` | | `RequestLine` | `RequestMethod` + `RequestPath` + `RequestProtocol` |
| `RequestContentSize` | The number of bytes in the request entity (a.k.a. body) sent by the client. | | `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. | | `OriginDuration` | The time taken by the origin server ('upstream') to return its response. |

View file

@ -45,8 +45,8 @@ func (f *CommonLogFormatter) Format(entry *logrus.Entry) ([]byte, error) {
toLog(entry.Data, "request_Referer", `"-"`, true), toLog(entry.Data, "request_Referer", `"-"`, true),
toLog(entry.Data, "request_User-Agent", `"-"`, true), toLog(entry.Data, "request_User-Agent", `"-"`, true),
toLog(entry.Data, RequestCount, defaultValue, true), toLog(entry.Data, RequestCount, defaultValue, true),
toLog(entry.Data, RouterName, defaultValue, true), toLog(entry.Data, RouterName, `"-"`, true),
toLog(entry.Data, ServiceURL, defaultValue, true), toLog(entry.Data, ServiceURL, `"-"`, true),
elapsedMillis) elapsedMillis)
return b.Bytes(), err return b.Bytes(), err

View file

@ -36,7 +36,7 @@ func TestCommonLogFormatter_Format(t *testing.T) {
RouterName: "", RouterName: "",
ServiceURL: "", 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
`, `,
}, },
{ {

View file

@ -449,7 +449,7 @@ func TestNewLogHandlerOutputStdout(t *testing.T) {
DefaultMode: "drop", DefaultMode: "drop",
}, },
}, },
expectedLog: `- - - [-] "- - -" - - "testReferer" "testUserAgent" - - - 0ms`, expectedLog: `- - - [-] "- - -" - - "testReferer" "testUserAgent" - "-" "-" 0ms`,
}, },
{ {
desc: "Default mode drop with override", 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", 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", 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", 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`,
}, },
} }