Hyper(tracing) logging in env_logger maner?

You must enable a Subscriber to do anything with the log messages created by tracing, like printing them to stdout. The tracing-subscriber crate provides a good Subscriber. Re-using the RUST_LOG environment variable and showing the hyper logs should be as easy as adding the following to your code:

Cargo.toml:

[dependencies]
tracing-subscriber = { version = "^0.3.16", features = ["env-filter"] }

main.rs:

fn main() {
    tracing_subscriber::fmt::init();
}

Here some more background:

4 Likes