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

[Question] logger sink question #3093

Closed
chenyongquan2 opened this issue May 23, 2024 · 1 comment
Closed

[Question] logger sink question #3093

chenyongquan2 opened this issue May 23, 2024 · 1 comment

Comments

@chenyongquan2
Copy link

How can I configure a logger to rotate the log files daily, while also rotating them based on the file size?

To achieve this, you can use the daily_file_sink_mt and size_file_sink_mt sinks provided by spdlog, and combine them together.

I Have tried

auto daily_sink = std::make_shared<spdlog::sinks::daily_file_sink_mt>(log_file_path, 2, 30);
auto rotating_file_sink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>(log_file_path, max_size, max_files, true); 
auto logger = std::make_shared<spdlog::logger>(name, std::initializer_list<spdlog::sink_ptr>{rotating_file_sink,daily_sink});

But it didn't turn out the way I expected.

@tt4g
Copy link
Contributor

tt4g commented May 23, 2024

Duplicate #2702

@gabime gabime closed this as completed May 24, 2024
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

3 participants