diff --git a/modules/log/log.go b/modules/log/log.go index 6ca6d3f7c12d0..8faf9416def4f 100644 --- a/modules/log/log.go +++ b/modules/log/log.go @@ -39,6 +39,17 @@ func NewLogger(bufLen int64, mode, config string) { } } +// DelLogger removes loggers that are for the given mode +func DelLogger(mode string) error { + for _, l := range loggers { + if _, ok := l.outputs[mode]; ok { + return l.DelLogger(mode) + } + } + Trace("Log adapter %s not found, no need to delete", mode) + return nil +} + // NewGitLogger create a logger for git // FIXME: use same log level as other loggers. func NewGitLogger(logPath string) { diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 9a8a52e1955f1..99a00d5c00435 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -867,6 +867,16 @@ func newLogService() { LogModes = strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",") LogConfigs = make([]string, len(LogModes)) + useConsole := false + for _, mode := range LogModes { + if mode == "console" { + useConsole = true + } + } + if (!useConsole) { + log.DelLogger("console") + } + for i, mode := range LogModes { mode = strings.TrimSpace(mode)