Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zap-logger with lumberjack not working #185

Open
jingc1413 opened this issue Mar 30, 2023 · 1 comment
Open

zap-logger with lumberjack not working #185

jingc1413 opened this issue Mar 30, 2023 · 1 comment

Comments

@jingc1413
Copy link

jingc1413 commented Mar 30, 2023

I test in windows environment
Integration tests for zap logger and lumberjack-rolling
find not working, no rotation

func WithFileRotationP(file string) Option {
	dir := filepath.Dir(file)
	if err := os.MkdirAll(dir, 0766); err != nil {
		panic(err)
	}

	return func(opt *option) {
		opt.file = &lumberjack.Logger{ 
			Filename:   file, 
			MaxSize:    1,    
			MaxBackups: 300,  
			MaxAge:     30,  
			LocalTime:  true, 
			Compress:   true,
		}
	}
}

output error:

2023-03-30 17:24:24.6335537 +0800 CST m=+3.052071301 write error: can't rename log file: rename ./test.log test-2023-03-30T17-24-24.633.log: The process cannot access the file because it is being used by another process.

When I switch to linux environment, it works fine

@steve-white
Copy link

I suspect this bug is because on Linux it's fine to rename a file even if it's in use, but not on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants