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

Anyway to add time-stamp to initial file name and NOT just rotated logs? #181

Open
daniel-res opened this issue Mar 7, 2023 · 1 comment

Comments

@daniel-res
Copy link

Looking to have a time-stamp on each file created (not just the rotated files). I've experiments with updating the file name formatting, such as

w := zapcore.AddSync(&lumberjack.Logger{

    Filename:   fmt.Sprintf("%s/dump-%v.log", logPath, time.Now().Format(time.RFC822)),
    MaxSize:    maxSize, 
    MaxBackups: maxBackUp,
    MaxAge:     maxAge, 
})

but it appears to affect rotated file logging

@rrajpuro
Copy link

rrajpuro commented Dec 4, 2023

This maybe a limitation in the way openNew() calls the newname := backupName(name, l.LocalTime) .

A better enhancement would be to just accept the log file prefix instead of log file name

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