Unable to enable anything above INFO logging

I'm experiencing a very perplexing problem trying to enable debug logging with rust.

I have tried stripping down everything to just a basic example program, using the example here:

Basically I have made a project with the first example program verbatim, and have compiled, and used the RUST_LOG=debug ./target/debug/test_debug_log, or RUST_LOG=debug cargo run, but I only get the WARN and INFO log messages.

I have even gone as far as trying to set the log level inside the program directly:

fn main() {
    env_logger::init();
    log::set_max_level(LevelFilter::Debug);
    if log_enabled!(Level::Debug) {
        println!("LOG LEVEL DEBUG");
    }
    warn!("[root] warn");
    info!("[root] info");
    debug!("[root] debug");
    foo::run();
}

And literally setting the max level via log, in the program, to debug, doesn't end up showing the print statement. If I switch the test to checking if 'Warn' or 'Info' is enabled, it will print the subsequent message.

Even setting max level to 'trace' or RUST_LOG=trace on the console doesn't seem to effect anything, and the only way I have been able to get the debug traces to show up has been to replace the debug! macro in my module with:

macro_rules! debug {
     ($($arg:tt)*) => (println!($($arg)*))
}

This seems so completely basic, that I'm sure I'm missing some obvious RTFM moment, but I have scoured over the documents, and it seems like this should work.

I cannot reproduce your experience:

[dependencies]
log = "0.4.6"
env_logger = "0.6.1"
use log::{debug, info, warn};

fn main() {
    env_logger::init();
    warn!("[root] warn");
    info!("[root] info");
    debug!("[root] debug");
}
$ RUST_LOG=debug ./target/debug/x
[2019-04-22T02:03:14Z WARN  x] [root] warn
[2019-04-22T02:03:14Z INFO  x] [root] info
[2019-04-22T02:03:14Z DEBUG x] [root] debug

Where does DEBUG_LOG come from?

Sorry, I meant RUST_LOG as in the previous examples.

Adding 'env_logger' at the same version you specified to my dependencies now causes DEBUG logs to appear.

Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.