Skip to content

Commit

Permalink
[Fix]滚动日志路径解析不正确
Browse files Browse the repository at this point in the history
例如  rotate:test.log 路径解析不正确
  • Loading branch information
mumuhhh authored and hexfusion committed Jun 9, 2021
1 parent b327edf commit fed3bc3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/embed/config_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ func (cfg *Config) setupLogging() error {
var path string
if cfg.EnableLogRotation {
// append rotate scheme to logs managed by lumberjack log rotation
path = fmt.Sprintf("rotate:%s", v)
if v[0:1] == "/" {
path = fmt.Sprintf("rotate:/%%2F%s", v[1:])
} else {
path = fmt.Sprintf("rotate:/%s", v)
}
} else {
path = v
}
Expand Down Expand Up @@ -254,7 +258,7 @@ func setupLogRotation(logOutputs []string, logRotateConfigJSON string) error {
}
}
zap.RegisterSink("rotate", func(u *url.URL) (zap.Sink, error) {
logRotationConfig.Filename = u.Path
logRotationConfig.Filename = u.Path[1:]
return &logRotationConfig, nil
})
return nil
Expand Down

0 comments on commit fed3bc3

Please sign in to comment.