Closed loggerheads-with-binary closed 1 month ago
I'm guessing the reason is that you set flush_level_filter(MoreSevereEqual(Warn))
for the logger, so the logs won't be flushed to a file unless there's a critical
, error
, warn
log, or if the internal buffer is full.
You can try setting up an automatic periodic flush via Logger::set_flush_period
, which will ensure that the logs are flushed into the file at the regular interval.
However, for AsyncPoolSink
+ File/RotatingFileSink
users, I recommend reading discussion #57 first so you will understand how they work internally, and then can reconsider whether AsyncPoolSink
is really needed here. (I might add it to the documentation later)
Hi, @SpriteOvO; thanks so much for the speedy and detailed answer.
You can try setting up an automatic periodic flush via Logger::set_flush_period, which will ensure that the logs are flushed into the file at the regular interval.
The Logger::set_flush_period
worked. Most of my logs were info level or below, so they never got forwarded.
Thanks a lot
I recommend reading discussion https://github.com/SpriteOvO/spdlog-rs/discussions/57 first so you will understand how they work internally
I did go through the ASyncPoolSink documentation. Personally, I was concerned about the stderr logger more than the file based one. If I understand correctly, the stderr in rust is unbuffered. So even inside of a buffer, it might block my operations. That is what I am primarily trying to avoid.
My application generates about 1 log/5ms. I am not sure if the stderr stream might be able to handle that in a way that does not impact performance. Which is why I was offloading that to the AsyncSink to forward it to a separate thread altogether.
Describe the bug
When running an async sink using a rotating file sink and a stderr sink, I am able to find all the logs correctly on the stderr, but none of them seem to be redirected to the rotating file sink. Note: I am using the log crate proxy to redirect application logs sent to the log crate.
To Reproduce
Steps to reproduce the behavior:
Setup log crate proxy
Expected behavior
File should also have the same logs as the stderr stream
Screenshots
Environments
Additional context
I am using the log crate proxy mechanism