diff --git a/conf/app.ini b/conf/app.ini index f20665eab..16a1e2cd0 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -143,9 +143,9 @@ HOST = PROVIDER = file ; Provider config options ; memory: not have any config yet -; file: session file path, e.g. data/sessions -; redis: config like redis server addr, poolSize, password, e.g. 127.0.0.1:6379,100,astaxie -; mysql: go-sql-driver/mysql dsn config string, e.g. root:password@/session_table +; file: session file path, e.g. "data/sessions" +; redis: config like redis server addr, poolSize, password, e.g. "127.0.0.1:6379,100,astaxie" +; mysql: go-sql-driver/mysql dsn config string, e.g. "root:password@/session_table" PROVIDER_CONFIG = data/sessions ; Session cookie name COOKIE_NAME = i_like_gogits @@ -169,6 +169,7 @@ DISABLE_GRAVATAR = false [log] ; Either "console", "file", "conn", "smtp" or "database", default is "console" +; Use comma to separate multiple modes, e.g. "console, file" MODE = console ; Buffer length of channel, keep it as it is if you don't know what it is. BUFFER_LEN = 10000 diff --git a/modules/base/conf.go b/modules/base/conf.go index 99bac9006..c38d33577 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -70,8 +70,8 @@ var ( MailService *Mailer OauthService *Oauther - LogMode string - LogConfig string + LogModes []string + LogConfigs []string Cache cache.Cache CacheAdapter string @@ -130,57 +130,62 @@ func newService() { } func newLogService() { - // Get and check log mode. - LogMode = Cfg.MustValue("log", "MODE", "console") - modeSec := "log." + LogMode - if _, err := Cfg.GetSection(modeSec); err != nil { - qlog.Fatalf("Unknown log mode: %s\n", LogMode) - } - - // Log level. - levelName := Cfg.MustValue("log."+LogMode, "LEVEL", "Trace") - level, ok := logLevels[levelName] - if !ok { - qlog.Fatalf("Unknown log level: %s\n", levelName) - } - - // Generate log configuration. - switch LogMode { - case "console": - LogConfig = fmt.Sprintf(`{"level":%s}`, level) - case "file": - logPath := Cfg.MustValue(modeSec, "FILE_NAME", "log/gogs.log") - os.MkdirAll(path.Dir(logPath), os.ModePerm) - LogConfig = fmt.Sprintf( - `{"level":%s,"filename":"%s","rotate":%v,"maxlines":%d,"maxsize":%d,"daily":%v,"maxdays":%d}`, level, - logPath, - Cfg.MustBool(modeSec, "LOG_ROTATE", true), - Cfg.MustInt(modeSec, "MAX_LINES", 1000000), - 1<
+ {{range .Loggers}}
Log Mode
-
{{.LogMode}}
+
{{.Mode}}
Log Config
-
{{.LogConfig}}
+
{{.Config}}
+ {{end}}