Using LogTracer
with a tracing subscriber
#2875
-
How can I write a program that configures a typical tracing subscriber (just using the types from I tried the following minimal code: use tracing_subscriber::filter::LevelFilter;
fn main() {
tracing_log::LogTracer::init().unwrap();
tracing_subscriber::fmt()
.with_max_level(LevelFilter::TRACE)
.init();
log::debug!("This is a log message.");
tracing::debug!("This is a tracing message.");
} on Rust 1.76 with these dependencies: [dependencies]
log = "0.4.20"
tracing = "0.1.40"
tracing-log = "0.2.0"
tracing-subscriber = "0.3.18" but it fails with:
Switching the order of the
|
Beta Was this translation helpful? Give feedback.
Answered by
criccomini
Jul 30, 2025
Replies: 1 comment 3 replies
-
Seeing the same issue. What am I missing? 😅 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Figured this out. Apparently if you use the default features for
tracing_subscriber
, it enablestracing-log
, which causesSubscriberBuilder.init()
to register with thelog
global logger. This prevents you from using the subscriber along sidetracing_log
. To fix this, you need to disable the default features fortracing_subscriber
:Here's a look at a diff that works: