-
Notifications
You must be signed in to change notification settings - Fork 789
max_log_files can‘ work #2937
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
Comments
I tried your example just now and it works perfectly. Creates a new file every minute and deletes the old one, so that there are always only two files. In which case does your file rolling 'not work'? Even if it somehow fails, I think it's unwise to start deleting files without having rolled over. Regarding the rolling over at a specific file size, there are a few PRs open: #2904 and #2497 both of which have not been merged yet! |
I agree when every minute we write log, creates a new file every minute and deletes the old one |
The thing is that we first call |
I have different idea about it that we first call |
It is my test:
every minute I run this progress, the file will never remove |
Oh, you are right. Though one could argue this is a weird use-case... |
But it is normal case on App and I try prune_old_logs at last it does work.By the way, entry.create is not supported on Android, so I change sort by file_name. Do you have any better idea? |
The prune_old_logs function only gets called when we rollover the appender. The problem is that at startup we create an initial log file without rolling over, if e.g., the executable then exits before rolling over for the first time, we never call prune_old_logs. E.g.: If we have a tracing-appender that rolls over every minute and we have a max_files parameter of 2. Running the program (which prints a single log line and exits) every minute, will result in a new log file everytime without deleting the old ones. Fixes: tokio-rs#2937
may be use mtime is better than create time, create time is not support for older linux version |
Yes, #3000 should fix this. |
Bug Report
Version
tracing = "0.1.40"
tracing-subscriber = {version = "0.3.18", features = ['env-filter', 'local-time']}
tracing-appender = "0.2.3"
Platform
macos、Android
Description
I found max_log_files not work
I try to find reason, and I found remove file only write->refresh_writer->prune_old_logs.
So can we add 'prune_old_logs' to 'Inner::new'? If write can't make file rolling, and file can't remove. I hope we can trim file when init tracing. By the way, can we set file size? I found some issue, but no code use
The text was updated successfully, but these errors were encountered: