feat: log to stdout & file (#2709)

pull/2715/head
BoYanZh 2022-12-14 13:19:08 +08:00 committed by GitHub
parent cdc45630ae
commit 6f4b1ba4b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -1,7 +1,9 @@
package bootstrap
import (
"io"
"log"
"os"
"github.com/alist-org/alist/v3/cmd/flags"
"github.com/alist-org/alist/v3/internal/conf"
@ -38,13 +40,14 @@ func Log() {
setLog(utils.Log)
logConfig := conf.Conf.Log
if logConfig.Enable {
logrus.SetOutput(&lumberjack.Logger{
mw := io.MultiWriter(os.Stdout, &lumberjack.Logger{
Filename: logConfig.Name,
MaxSize: logConfig.MaxSize, // megabytes
MaxBackups: logConfig.MaxBackups,
MaxAge: logConfig.MaxAge, //days
Compress: logConfig.Compress, // disabled by default
})
logrus.SetOutput(mw)
}
utils.Log.Infof("init logrus...")
}