DEFMT_LOG variable not setting properly to change logging levels in Defmt crate


I'm currently trying to set the DEFMT_LOG environment variable in the Windows Command Prompt (cmd) to enable different logging levels for my Rust application that uses defmt. I'm encountering an issue where it appears that the environment variable isn't getting set properly, despite running the command in the same cmd session.

Here is what I have tried:

  • I set the DEFMT_LOG environment variable using the command set DEFMT_LOG=trace.
  • I'm running my Rust application using cargo run in the same cmd session right after setting the environment variable.

Despite these steps, it doesn't appear that DEFMT_LOG is being recognized by my application. The log output doesn't change to reflect the trace level, and it seems to be stuck at the default error level.

I am using the Defmt version 0.3.2

Despite all of these, I'm still facing this issue. I would really appreciate if anyone could help me troubleshoot what might be going wrong here.

Thank you in advance for your assistance.

Does your application get recompiled after setting the env var? If not try cargo clean. Defmt reads the env var only at compile time.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.