Default to CLF when accesslog format is unsupported

This commit is contained in:
mpl 2019-09-09 09:24:03 +02:00 committed by Traefiker Bot
parent d044c0f4cc
commit 605a9b2817
2 changed files with 3 additions and 3 deletions

View file

@ -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"

View file

@ -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{