diff --git a/docs/content/observability/access-logs.md b/docs/content/observability/access-logs.md index 2c00e9dd2..5e6551a51 100644 --- a/docs/content/observability/access-logs.md +++ b/docs/content/observability/access-logs.md @@ -26,12 +26,11 @@ accessLog: {} By default access logs are written to the standard output. To write the logs into a log file, use the `filePath` option. -in the Common Log Format (CLF), extended with additional fields. - ### `format` 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. !!! note "Common Log Format" diff --git a/pkg/middlewares/accesslog/logger.go b/pkg/middlewares/accesslog/logger.go index 4cce7fe06..1f6b80b4b 100644 --- a/pkg/middlewares/accesslog/logger.go +++ b/pkg/middlewares/accesslog/logger.go @@ -77,7 +77,8 @@ func NewHandler(config *types.AccessLog) (*Handler, error) { case JSONFormat: formatter = new(logrus.JSONFormatter) default: - return nil, fmt.Errorf("unsupported access log format: %s", config.Format) + log.WithoutContext().Errorf("unsupported access log format: %q, defaulting to common format instead.", config.Format) + formatter = new(CommonLogFormatter) } logger := &logrus.Logger{