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

Rotate files was not triggered #167

Closed
longzou opened this issue Jul 25, 2024 · 1 comment
Closed

Rotate files was not triggered #167

longzou opened this issue Jul 25, 2024 · 1 comment
Labels

Comments

@longzou
Copy link

longzou commented Jul 25, 2024

The logger's configure as below:

Logger::with(logger_builder.build()).format(fmt)
.adaptive_format_for_stdout(flexi_logger::AdaptiveFormat::WithThread)
.cleanup_in_background_thread(true)
.append()
.print_message()
.rotate(flexi_logger::Criterion::Size(8196), flexi_logger::Naming::Timestamps, flexi_logger::Cleanup::KeepLogFiles(5))
.write_mode(write_mode);

The log files was not removed during the app running.

@emabee
Copy link
Owner

emabee commented Jul 25, 2024

You need to use log_to_file to tell flexi_logger that it should write its output to files, and which files this should be. Only then will the rotation config become relevant.

PS: flexi_logger does not use different types for its builder - this could be used to e.g. enable use of rotate only if log_to_file was used before; the compiler would then help to avoid such issues. Earlier attempts of doing so resulted in an API doc that was much harder to read, so I abdicated it.

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

No branches or pull requests

2 participants