go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

KeepDays doesn't work on windows

Open jurannameshuai opened this issue 2 years ago • 3 comments
trafficstars

Windows 系统下logx设置了KeepDays无法正常删除过期日志, 问题代码 core/logx/writer.go:133 accessFile := path.Join(c.Path, accessFilename) 拿到的 目录地址为 ”logs/access.log“ 后续删除时的判断: core/logx/rotatelogger.go:126
for _, file := range files { if file < boundaryFile { outdates = append(outdates, file) } } 此时 file为 ”logs/access***.log“ ,boundaryFile 为“logs\access***.log”,因分隔符不对,file < boundaryFile 判断不准,导致windows系统下不会删除过期的日志文件。同理,Rotation 为size时 rename文件也会有问题。

jurannameshuai avatar May 12 '23 08:05 jurannameshuai

Are you running your services on windows for production?

kevwan avatar May 13 '23 15:05 kevwan

Yes, I used the go-zero to write some small go programs that work on Windows

jurannameshuai avatar May 15 '23 01:05 jurannameshuai

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar May 21 '24 01:05 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Aug 22 '24 01:08 github-actions[bot]