diff --git a/dendrite-config.yaml b/dendrite-config.yaml index 6e2326595..fa915e503 100644 --- a/dendrite-config.yaml +++ b/dendrite-config.yaml @@ -117,6 +117,13 @@ listen: tracing: # Config for the jaeger opentracing reporter. # See https://godoc.org/github.com/uber/jaeger-client-go/config#Configuration - # for documtation. + # for documentation. jaeger: disabled: true + +# The configuration for logs of dendrite +logging: + # The logging level, must be one of debug, info, warn, error, fatal, panic. + level: "info" + # The file on which save logs. If commented, logs won't be saved by dendrite and only printed to stdout + # path: /var/log/dendrite.log diff --git a/src/github.com/matrix-org/dendrite/common/config/config.go b/src/github.com/matrix-org/dendrite/common/config/config.go index f291a076d..5cfb4b797 100644 --- a/src/github.com/matrix-org/dendrite/common/config/config.go +++ b/src/github.com/matrix-org/dendrite/common/config/config.go @@ -206,6 +206,15 @@ type Dendrite struct { Jaeger jaegerconfig.Configuration `yaml:"jaeger"` } + // The config for logging informations + Logging struct { + // The path to the log file + FPath Path `yaml:"path"` + + // The logging level + Level string `yaml:"level"` + } `yaml:"logging"` + // Any information derived from the configuration options for later use. Derived struct { Registration struct { @@ -219,6 +228,9 @@ type Dendrite struct { // registration in order to complete registration stages. Params map[string]interface{} `json:"params"` } + + // The logrus level used for logging configuration + LogLevel logrus.Level } } @@ -472,6 +484,12 @@ func (config *Dendrite) check(monolithic bool) error { checkNotEmpty("listen.room_server", string(config.Listen.RoomServer)) } + if level, err := logrus.ParseLevel(config.Logging.Level); err != nil { + problems = append(problems, fmt.Sprintf("Invalid value for key logging.level: %s", config.Logging.Level)) + } else { + config.Derived.LogLevel = level + } + if problems != nil { return Error{problems} } diff --git a/src/github.com/matrix-org/dendrite/common/config/config_test.go b/src/github.com/matrix-org/dendrite/common/config/config_test.go index 24b0dfc1f..5d3b40cd9 100644 --- a/src/github.com/matrix-org/dendrite/common/config/config_test.go +++ b/src/github.com/matrix-org/dendrite/common/config/config_test.go @@ -59,6 +59,9 @@ listen: federation_api: "localhost:7772" sync_api: "localhost:7773" media_api: "localhost:7774" +logging: + level: "debug" + path: "/my/log/dir/dendrite.log" ` type mockReadFile map[string]string