Skip to content

Commit f84bee1

Browse files
author
刘翔鹏
committed
设置日志滚动分割时间为24小时一次
1 parent 2eb7c31 commit f84bee1

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

log/logger/segment.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ func NewLfsHook(l *logrus.Logger, logDir, name string) (*lfshook.LfsHook, error)
2222
infoWriter, err = rotatelogs.New(
2323
infoPath,
2424
rotatelogs.WithLinkName(linkInfoPath),
25-
rotatelogs.WithMaxAge(time.Duration(86400)*time.Second),
26-
rotatelogs.WithRotationTime(time.Duration(604800)*time.Second),
25+
rotatelogs.WithRotationTime(time.Duration(24)*time.Hour),
2726
)
2827
if err != nil {
2928
return nil, err
@@ -34,8 +33,7 @@ func NewLfsHook(l *logrus.Logger, logDir, name string) (*lfshook.LfsHook, error)
3433
warnWriter, err = rotatelogs.New(
3534
warnPath,
3635
rotatelogs.WithLinkName(linkWarnPath),
37-
rotatelogs.WithMaxAge(time.Duration(86400)*time.Second),
38-
rotatelogs.WithRotationTime(time.Duration(604800)*time.Second),
36+
rotatelogs.WithRotationTime(time.Duration(24)*time.Hour),
3937
)
4038
if err != nil {
4139
return nil, err
@@ -46,8 +44,7 @@ func NewLfsHook(l *logrus.Logger, logDir, name string) (*lfshook.LfsHook, error)
4644
errorWriter, err = rotatelogs.New(
4745
errorPath,
4846
rotatelogs.WithLinkName(linkErrorPath),
49-
rotatelogs.WithMaxAge(time.Duration(86400)*time.Second),
50-
rotatelogs.WithRotationTime(time.Duration(604800)*time.Second),
47+
rotatelogs.WithRotationTime(time.Duration(24)*time.Hour),
5148
)
5249
if err != nil {
5350
return nil, err

0 commit comments

Comments
 (0)