You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2025/09/07 08:15:13 UTC
(dubbo-go) branch develop updated: fix: correct log rotation path to prevent file loss (#3014)
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/develop by this push:
new 49ff7c64c fix: correct log rotation path to prevent file loss (#3014)
49ff7c64c is described below
commit 49ff7c64c151880946d344ece28e52ee8bfb3875
Author: Xibei <20...@stu.sicau.edu.cn>
AuthorDate: Sun Sep 7 16:15:09 2025 +0800
fix: correct log rotation path to prevent file loss (#3014)
* fix(filter): correct log rotation path to prevent file loss
- use full path (accessLog) instead of fileInfo.Name() in os.Rename
- avoids rename failure when cwd differs from log dir
- prevents log rotation breakage and disk fill-up
* Update filter/accesslog/filter.go
Fix grammar error
Co-authored-by: Copilot <17...@users.noreply.github.com>
---------
Co-authored-by: Copilot <17...@users.noreply.github.com>
---
filter/accesslog/filter.go | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/filter/accesslog/filter.go b/filter/accesslog/filter.go
index 398a91ac1..c5865b146 100644
--- a/filter/accesslog/filter.go
+++ b/filter/accesslog/filter.go
@@ -229,10 +229,11 @@ func (f *Filter) openLogFile(accessLog string) (*os.File, error) {
// and today is '2020-03-05'
// we will create one new file to log access data
// By this way, we can split the access log based on days.
+ // use 'accessLog' as complete path to avoid log not found.
if now != last {
- err = os.Rename(fileInfo.Name(), fileInfo.Name()+"."+now)
+ err = os.Rename(accessLog, accessLog+"."+now)
if err != nil {
- logger.Warnf("Can not rename access log file: %s, %v", fileInfo.Name(), err)
+ logger.Warnf("Can not rename access log file: %s, %v", accessLog, err)
return nil, err
}
logFile, err = os.OpenFile(accessLog, os.O_CREATE|os.O_APPEND|os.O_RDWR, LogFileMode)