I'm trying to use the tracing framework when making a web server. When I use tracing and send requests, there will be log output from the hyper crate. How do I filter out these logs and keep the logs of my application itself?
I have this code:
let filter: EnvFilter = "hyper=debug".parse().expect("filter should parse");
let logger = Registry::default()
.with(EnvFilter::from_default_env().add_directive(log_env.into()).with_filter(filter))
.with(fmt::Layer::default().event_format(format));
tracing::subscriber::set_global_default(logger).unwrap();
but it does not work for me.
in your
Cargo.tomltracing-subscriber = {version="0.3", features=["env-filter"]}in your code:
then:
RUST_LOG=my_crate=DEBUG cargo run