-
Hello, First off: thanks for your crate! the auto rotating logger is a very nice feature. My application is 100% asynchronous (based off Tokio + Tonic), does that mean I have to use the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
tl;dr: You don't have to use Full explanationFor file sinks, the bottleneck will not be happening on the To avoid this bottleneck by default, (Tip: Explicit flushes can be performed by manually calling For The best cases for using |
Beta Was this translation helpful? Give feedback.
tl;dr: You don't have to use
AsyncPoolSink
if you are just writing log to file (with not very verbose flush_level_filter value).Full explanation
For file sinks, the bottleneck will not be happening on the
Arc
(accessing aArc
is almost zero-cost, just one more indirect pointer access), but will be in the internal locks for writing data tostd::fs::File
.To avoid this bottleneck by default,
spdlog-rs
has already wrapped theFile
object withstd::io::BufWriter
. The effect of this behavior is that data writes are not actually performed to the filesystem, but are cached in theBufWriter
until the buffer is full or flushed explicitly.(Tip: Explicit flushes can be performed by manually calling