--- layout: post title: "The Surprising Price of Log Filtering" categories: rust,programming author: eliza --- # The Surprising Price of Log Filtering (or, "How Tracing Makes Logging Faster By Making It More Complicated") This is a story about turning things off, and the surprising cost of doing so. Recently, I stumbled across a hidden performance cost that a pretty large number of Rust applications may be paying, probably unknowingly. In order to shine a little light on that cost — and how library authors can help their users avoid paying it — we're going to look under the hood of a couple widely-used crates and examine some interesting design decisions that lead us here. > **A disclaimer**: This post discusses the relative performance of two libraries > in the Rust ecosystem, `log` and `tracing`, which provide similar functionality. > I'm the maintainer of one of these libraries, so my outlook is, of course, > somewhat biased. Furthermore, although I make some suggestions for users > concerned about performance towards the end of the post, this is _not_ intended > as "`log` considered harmful". Although `tracing` and `log` occupy a similar > niche, I don't necessarily view these crates as competitors.