diff options
author | zeripath <art27@cantab.net> | 2020-05-16 03:38:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-15 22:38:52 -0400 |
commit | 0052d788daf0bdc938d6189da880b5113a1113c6 (patch) | |
tree | 35c2bbd88feb4ce4ec5a907891bc19665d434bf7 | |
parent | 1d54479585362c67ec5a6779df5b2bde874252a3 (diff) | |
download | gitea-0052d788daf0bdc938d6189da880b5113a1113c6.tar.gz gitea-0052d788daf0bdc938d6189da880b5113a1113c6.zip |
Allow log.xxx.default to set logging settings for the default logger only (#11292)
* Allow log.xxx.default to set logging settings for the default logger only
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Update modules/setting/log.go
* as per @silverwind add some documentation
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
-rw-r--r-- | docs/content/doc/advanced/logging-documentation.en-us.md | 15 | ||||
-rw-r--r-- | modules/setting/log.go | 7 |
2 files changed, 18 insertions, 4 deletions
diff --git a/docs/content/doc/advanced/logging-documentation.en-us.md b/docs/content/doc/advanced/logging-documentation.en-us.md index 73c8d5dcbc..919ccf783b 100644 --- a/docs/content/doc/advanced/logging-documentation.en-us.md +++ b/docs/content/doc/advanced/logging-documentation.en-us.md @@ -48,8 +48,10 @@ Calls to `log.Info`, `log.Debug`, `log.Error` etc. from the `code.gitea.io/gitea You can configure the outputs of this logger by setting the `MODE` value in the `[log]` section of the configuration. -Each output sublogger is configured in a separate `[log.sublogger]` -section, but there are certain default values. These will not be inherited from the `[log]` section: +Each output sublogger is configured in a separate `[log.sublogger.default]` +which inherits from the sublogger `[log.sublogger]` section and from the +generic `[log]` section, but there are certain default values. These will +not be inherited from the `[log]` section: * `FLAGS` is `stdflags` (Equal to `date,time,medfile,shortfuncname,levelinitial`) @@ -70,6 +72,9 @@ section which you can configure the outputs of by setting the `MACARON` value in the `[log]` section of the configuration. `MACARON` defaults to `file` if unset. +Please note, the macaron logger will log at `INFO` level, setting the +`LEVEL` of this logger to `WARN` or above will result in no macaron logs. + Each output sublogger for this logger is configured in `[log.sublogger.macaron]` sections. There are certain default values which will not be inherited from the `[log]` or relevant @@ -98,6 +103,9 @@ Router logs the same data as the Macaron log but has slightly different coloring. It logs at the `Info` level by default, but this can be changed if desired by setting the `ROUTER_LOG_LEVEL` value. +Please note, setting the `LEVEL` of this logger to a level above +`ROUTER_LOG_LEVEL` will result in no router logs. + Each output sublogger for this logger is configured in `[log.sublogger.router]` sections. There are certain default values which will not be inherited from the `[log]` or relevant @@ -136,6 +144,9 @@ which will not be inherited from the `[log]` or relevant If desired the format of the Access logger can be changed by changing the value of the `ACCESS_LOG_TEMPLATE`. +Please note, the access logger will log at `INFO` level, setting the +`LEVEL` of this logger to `WARN` or above will result in no access logs. + NB: You can redirect the access logger to send its events to the Gitea log using the value: `ACCESS = ,` diff --git a/modules/setting/log.go b/modules/setting/log.go index e7a4658006..5ffb2479dd 100644 --- a/modules/setting/log.go +++ b/modules/setting/log.go @@ -261,9 +261,12 @@ func newLogService() { continue } - sec, err := Cfg.GetSection("log." + name) + sec, err := Cfg.GetSection("log." + name + ".default") if err != nil { - sec, _ = Cfg.NewSection("log." + name) + sec, err = Cfg.GetSection("log." + name) + if err != nil { + sec, _ = Cfg.NewSection("log." + name) + } } provider, config, levelName := generateLogConfig(sec, name, options) |