Skip to content

Leveled logging is ignoring RUST_LOG #2993

@abatilo

Description

@abatilo

Bug Report

Version

aaron@Aarons-MacBook-Pro:~/temp/trace-example|main⚡ ⇒  cat Cargo.toml
[package]
name = "trace-example"
version = "0.1.0"
edition = "2021"

[dependencies]
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["json"] }

Platform

⇒  uname -a
Darwin Aarons-MacBook-Pro.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:14:38 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6020 arm64

Description

Here is my sample code where I try to print both info and debug logs:

use tracing::{debug, info};
use tracing_subscriber;

fn main() {
    tracing_subscriber::fmt().json().init();
    info!("INFO Hello World!");
    debug!("DEBUG Hello World!");
}

And here are the outputs. With RUST_LOG=info, I see the info log:

⇒  RUST_LOG=info cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/trace-example`
{"timestamp":"2024-06-02T16:43:10.361401Z","level":"INFO","fields":{"message":"INFO Hello World!"},"target":"trace_example"}

And with RUST_LOG=debug, I still only see the info log:

⇒  RUST_LOG=debug cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/trace-example`
{"timestamp":"2024-06-02T16:43:25.109736Z","level":"INFO","fields":{"message":"INFO Hello World!"},"target":"trace_example"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions