Fix log to file not work (#20541)

Signed-off-by: Enwei Jiao <enwei.jiao@zilliz.com>

Signed-off-by: Enwei Jiao <enwei.jiao@zilliz.com>
pull/20557/head
Enwei Jiao 2022-11-14 14:23:07 +08:00 committed by GitHub
parent b11df55499
commit b37a9c5fe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 9 deletions

View File

@ -18,10 +18,9 @@ package roles
import (
"context"
"fmt"
"os"
"os/signal"
"path"
"strconv"
"strings"
"sync"
"syscall"
@ -188,11 +187,7 @@ func (mr *MilvusRoles) setupLogger() {
roleName := paramtable.GetRole()
rootPath := logConfig.File.RootPath
if rootPath != "" {
if id < 0 {
logConfig.File.Filename = path.Join(rootPath, roleName+".log")
} else {
logConfig.File.Filename = path.Join(rootPath, roleName+"-"+strconv.FormatInt(id, 10)+".log")
}
logConfig.File.Filename = fmt.Sprintf("%s-%d.log", roleName, id)
} else {
logConfig.File.Filename = ""
}
@ -238,8 +233,6 @@ func (mr *MilvusRoles) Run(local bool, alias string) {
paramtable.Init()
}
mr.setupLogger()
if os.Getenv(metricsinfo.DeployModeEnvKey) == metricsinfo.StandaloneDeployMode {
closer := trace.InitTracing("standalone")
if closer != nil {
@ -312,6 +305,8 @@ func (mr *MilvusRoles) Run(local bool, alias string) {
}
}
mr.setupLogger()
metrics.Register(Registry)
management.ServeHTTP()
sc := make(chan os.Signal, 1)