Add GenericCLF log format for access logs
This commit is contained in:
parent
a051f20876
commit
e2282b1379
11 changed files with 234 additions and 18 deletions
|
|
@ -69,27 +69,43 @@ accessLog:
|
|||
|
||||
_Optional, Default="common"_
|
||||
|
||||
By default, logs are written using the Common Log Format (CLF).
|
||||
To write logs in JSON, use `json` in the `format` option.
|
||||
If the given format is unsupported, the default (CLF) is used instead.
|
||||
By default, logs are written using the Traefik Common Log Format (CLF).
|
||||
The available log formats are:
|
||||
|
||||
!!! info "Common Log Format"
|
||||
- `common` - Traefik's extended CLF format (default)
|
||||
- `genericCLF` - Generic CLF format compatible with standard log analyzers
|
||||
- `json` - JSON format for structured logging
|
||||
|
||||
If the given format is unsupported, the default (`common`) is used instead.
|
||||
|
||||
!!! info "Traefik Common Log Format vs Generic CLF"
|
||||
|
||||
**Traefik Common Log Format (`common`):**
|
||||
```html
|
||||
<remote_IP_address> - <client_user_name_if_available> [<timestamp>] "<request_method> <request_path> <request_protocol>" <HTTP_status> <content-length> "<request_referrer>" "<request_user_agent>" <number_of_requests_received_since_Traefik_started> "<Traefik_router_name>" "<Traefik_server_URL>" <request_duration_in_ms>ms
|
||||
```
|
||||
|
||||
**Generic CLF Format (`genericCLF`):**
|
||||
```html
|
||||
<remote_IP_address> - <client_user_name_if_available> [<timestamp>] "<request_method> <request_path> <request_protocol>" <HTTP_status> <content-length> "<request_referrer>" "<request_user_agent>"
|
||||
```
|
||||
|
||||
The `genericCLF` format omits Traefik-specific fields (request count, router name, service URL, and duration) for better compatibility with standard CLF parsers.
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
# JSON format
|
||||
accessLog:
|
||||
format: "json"
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
# JSON format
|
||||
[accessLog]
|
||||
format = "json"
|
||||
```
|
||||
|
||||
```bash tab="CLI"
|
||||
# JSON format
|
||||
--accesslog.format=json
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -155,8 +155,9 @@ When the `observability` options are not defined on a router, it inherits the be
|
|||
|
||||
Traefik Proxy supports the following log formats:
|
||||
|
||||
- Common Log Format (CLF)
|
||||
- JSON
|
||||
- `common` - Traefik's extended CLF format (default)
|
||||
- `genericCLF` - Generic CLF format compatible with standard log analyzers
|
||||
- `json` - JSON format for structured logging
|
||||
|
||||
## Access Log Filters
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ THIS FILE MUST NOT BE EDITED BY HAND
|
|||
| accesslog.filters.minduration | Keep access logs when request took longer than the specified duration. | 0 |
|
||||
| accesslog.filters.retryattempts | Keep access logs when at least one retry happened. | false |
|
||||
| accesslog.filters.statuscodes | Keep access logs with status codes in the specified range. | |
|
||||
| accesslog.format | Access log format: json | common | common |
|
||||
| accesslog.format | Access log format: json, common, or genericCLF | common |
|
||||
| accesslog.otlp | Settings for OpenTelemetry. | false |
|
||||
| accesslog.otlp.grpc | gRPC configuration for the OpenTelemetry collector. | false |
|
||||
| accesslog.otlp.grpc.endpoint | Sets the gRPC endpoint (host:port) of the collector. | localhost:4317 |
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ The section below describes how to configure Traefik access logs using the stati
|
|||
| Field | Description | Default | Required |
|
||||
|:-----------|:--------------------------|:--------|:---------|
|
||||
| `accesslog.filePath` | By default, the access logs are written to the standard output.<br />You can configure a file path instead using the `filePath` option.| | No |
|
||||
| `accesslog.format` | By default, logs are written using the Common Log Format (CLF).<br />To write logs in JSON, use `json` in the `format` option.<br />If the given format is unsupported, the default (CLF) is used instead.<br />More information about CLF fields [here](#clf-format-fields). | "common" | No |
|
||||
| `accesslog.format` | By default, logs are written using the Traefik Common Log Format (CLF).<br />Available formats: `common` (Traefik's extended CLF), `genericCLF` (standard CLF compatible with analyzers), or `json`.<br />If the given format is unsupported, the default (`common`) is used instead.<br />More information about CLF fields [here](#clf-format-fields). | "common" | No |
|
||||
| `accesslog.bufferingSize` | To write the logs in an asynchronous fashion, specify a `bufferingSize` option.<br />This option represents the number of log lines Traefik will keep in memory before writing them to the selected output.<br />In some cases, this option can greatly help performances.| 0 | No |
|
||||
| `accesslog.addInternals` | Enables access logs for internal resources (e.g.: `ping@internal`). | false | No |
|
||||
| `accesslog.filters.statusCodes` | Limit the access logs to requests with a status codes in the specified range. | [ ] | No |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue